Skip to content

Commit

Permalink
✨ update app.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
tonystrawberry committed Nov 8, 2023
1 parent 8fcf420 commit f9373ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions lambda-jobs/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.process(event:, context:)
when 'giphy'
# Get random GIFs from Giphy API
# URL: https://api.giphy.com/v1/gifs/search?api_key=&q=lgtm&limit=50&offset=0&rating=g&lang=en&bundle=messaging_non_clips
URI("https://api.giphy.com/v1/gifs/search?api_key=#{ENV["GIPHY_API_KEY"]}&q=#{event['keyword']}&limit=20&offset=0&rating=g&lang=en&bundle=messaging_non_clips&sort=relevant")
URI("https://api.giphy.com/v1/gifs/random?api_key=#{ENV["GIPHY_API_KEY"]}&tag=#{event['keyword']}")
else
puts "[#process] Error: Invalid source"
return { "success": false }
Expand Down Expand Up @@ -55,14 +55,13 @@ def self.process(event:, context:)
# Parse the JSON response
json_data = JSON.parse(response.body)

results = json_data["data"]
results.map do |result|
{
'id' => result["id"],
'url' => result["images"]["original"]["url"],
'source' => 'giphy',
}
end
result = json_data["data"]

[{
'id' => result["id"],
'url' => result["images"]["original"]["url"],
'source' => 'giphy',
}]
when 'unsplash'
# Parse the JSON response
json_data = JSON.parse(response.body)
Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/eventbridge/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
resource "aws_cloudwatch_event_rule" "lgtm_job_aws_cloudwatch_event_rule" {
name = "lgtm-tonystrawberry-codes-job"
description = "EventBridge rule to trigger `lgtm-tonystrawberry-codes-job` Lambda function every hour"
schedule_expression = "cron(0 * * * ? *)"
schedule_expression = "cron(*/5 * * * ? *)"
}

# Create a target for the EventBridge rule to trigger the Lambda function with a payload
Expand Down

0 comments on commit f9373ff

Please sign in to comment.