diff --git a/Gemfile b/Gemfile index 47f326a1..3421828c 100644 --- a/Gemfile +++ b/Gemfile @@ -176,8 +176,6 @@ gem "turbo-rails" gem "sprockets-rails", require: "sprockets/railtie" -# Jard is an improvement on Byebug -gem "ruby_jard" gem "pry-byebug" # Add the ability to load `.env` files on launch diff --git a/Gemfile.lock b/Gemfile.lock index 42941b52..bf88df38 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -569,10 +569,6 @@ GEM ruby-vips (2.2.2) ffi (~> 1.12) logger - ruby_jard (0.3.1) - byebug (>= 9.1, < 12.0) - pry (~> 0.13.0) - tty-screen (~> 0.8.1) rubyntlm (0.6.3) rubyzip (2.3.2) safe_type (1.1.1) @@ -686,7 +682,6 @@ GEM bindata (~> 2.4) openssl (> 2.0, < 3.1) openssl-signature_algorithm (~> 1.0) - tty-screen (0.8.1) turbo-rails (1.3.0) actionpack (>= 6.0.0) activejob (>= 6.0.0) @@ -801,7 +796,6 @@ DEPENDENCIES rubocop-sorbet ruby-lsp ruby-progressbar - ruby_jard rubyzip selenium-webdriver shrine! diff --git a/app/jobs/send_scrape_email_job.rb b/app/jobs/send_scrape_email_job.rb new file mode 100644 index 00000000..6e26c79c --- /dev/null +++ b/app/jobs/send_scrape_email_job.rb @@ -0,0 +1,9 @@ +class SendScrapeEmailJob < ApplicationJob + queue_as :default + retry_on StandardError, wait: 2.minutes, attempts: 5 + + def perform(scrape) + logger.info "Sending completion email for scrape #{scrape.id}" + scrape.send_completion_email + end +end diff --git a/app/models/scrape.rb b/app/models/scrape.rb index a2dc5332..d34ae4ad 100644 --- a/app/models/scrape.rb +++ b/app/models/scrape.rb @@ -43,7 +43,6 @@ def perform ssl_verifyhost: 0 ) - json_error_response = JSON.parse(response.body) if response.code != 200 if response.code == 400 && json_error_response.nil? == false && json_error_response["code"] == 10 @@ -112,6 +111,7 @@ def fulfill(response) errored = true # For later in case the option for `status` could be something else end end + # debugger # Process everything correctly now that we know it's not removed media_review_item = self.media_review @@ -134,7 +134,7 @@ def fulfill(response) self.send_notification # Send the completion email or whatever if necessary - self.send_completion_email + SendScrapeEmailJob.perform_later(self) rescue StandardError => e logger.error "Error fulfilling scrape: #{e}" Honeybadger.notify(e, context: { diff --git a/app/models/sources/facebook_post.rb b/app/models/sources/facebook_post.rb index d5c665b8..230d9679 100644 --- a/app/models/sources/facebook_post.rb +++ b/app/models/sources/facebook_post.rb @@ -105,6 +105,11 @@ def self.create_from_forki_hash(forki_posts, user = nil) if forki_post["aws_image_keys"].present? downloaded_path = AwsS3Downloader.download_file_in_s3_received_from_hypatia(forki_post["aws_image_keys"]) image_attributes = [ { image: File.open(downloaded_path, binmode: true) } ] + elsif forki_post["aws_video_keys"].present? + video_attributes = forki_post["aws_video_keys"].map do |key| + downloaded_path = AwsS3Downloader.download_file_in_s3_received_from_hypatia(key) + { video: File.open(downloaded_path, binmode: true) } + end elsif forki_post["aws_video_key"].present? downloaded_path = AwsS3Downloader.download_file_in_s3_received_from_hypatia(forki_post["aws_video_key"]) video_attributes = [ { video: File.open(downloaded_path, binmode: true) } ] diff --git a/test/jobs/send_scrape_email_job_test.rb b/test/jobs/send_scrape_email_job_test.rb new file mode 100644 index 00000000..9e7ca898 --- /dev/null +++ b/test/jobs/send_scrape_email_job_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class SendScrapeEmailJobTest < ActiveJob::TestCase + # test "the truth" do + # assert true + # end +end