From 70559341d9a493c2b42c837196d5ab1642812148 Mon Sep 17 00:00:00 2001 From: starswan Date: Wed, 4 Dec 2024 17:25:17 +0000 Subject: [PATCH] review comments --- Gemfile.lock | 2 ++ app/jobs/alert_email/base.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c5d210f876..de3719eef6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -701,6 +701,7 @@ GEM unicode (0.4.4.5) unicode-display_width (2.6.0) uri (1.0.2) + uri-query_params (0.8.2) useragent (0.16.10) valid_email2 (7.0.0) activemodel (>= 6.0) @@ -860,6 +861,7 @@ DEPENDENCIES slim_lint solargraph tzinfo-data + uri-query_params valid_email2 validate_url vcr diff --git a/app/jobs/alert_email/base.rb b/app/jobs/alert_email/base.rb index a8920d979f..ed4214de6a 100644 --- a/app/jobs/alert_email/base.rb +++ b/app/jobs/alert_email/base.rb @@ -8,10 +8,10 @@ def perform # really fast (1 week's worth of vacancies is around 2000, so not worth leaving on disk for each of 100k daily subscriptions default_scope = Vacancy.includes(:organisations).live.order(publish_on: :desc).search_by_filter(from_date: from_date, to_date: Date.current) - already_run_ids = AlertRun.for_today.map(&:subscription_id) + already_run_ids = AlertRun.for_today.pluck(:subscription_id) subscriptions.find_each.reject { |sub| already_run_ids.include?(sub.id) }.each do |subscription| - vacancies = subscription.vacancies_matching default_scope + vacancies = subscription.vacancies_matching(default_scope).first(MAXIMUM_RESULTS_PER_RUN) Jobseekers::AlertMailer.alert(subscription.id, vacancies.pluck(:id)).deliver_later if vacancies.any? end