From 388de175e7dbfe051dcc7a62bb52d11e4e6ff78f Mon Sep 17 00:00:00 2001 From: starswan Date: Thu, 19 Dec 2024 14:45:05 +0000 Subject: [PATCH 1/5] fix job alert overlap --- app/jobs/alert_email/base.rb | 2 +- app/jobs/send_daily_alert_email_job.rb | 2 +- app/jobs/send_weekly_alert_email_job.rb | 2 +- spec/jobs/send_daily_alert_email_job_spec.rb | 2 +- spec/jobs/send_weekly_alert_email_job_spec.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/jobs/alert_email/base.rb b/app/jobs/alert_email/base.rb index b7e3cb9253..7d64d9427e 100644 --- a/app/jobs/alert_email/base.rb +++ b/app/jobs/alert_email/base.rb @@ -14,6 +14,6 @@ def perform end def vacancies_for_subscription(subscription) - subscription.vacancies_for_range(from_date, Date.current) + subscription.vacancies_for_range(from_date, Date.yesterday) end end diff --git a/app/jobs/send_daily_alert_email_job.rb b/app/jobs/send_daily_alert_email_job.rb index 62f81465e8..673a4ce6e1 100644 --- a/app/jobs/send_daily_alert_email_job.rb +++ b/app/jobs/send_daily_alert_email_job.rb @@ -6,6 +6,6 @@ def subscriptions end def from_date - Time.zone.yesterday + 2.days.ago.to_date end end diff --git a/app/jobs/send_weekly_alert_email_job.rb b/app/jobs/send_weekly_alert_email_job.rb index 98cdf2d326..0ccc26570f 100644 --- a/app/jobs/send_weekly_alert_email_job.rb +++ b/app/jobs/send_weekly_alert_email_job.rb @@ -6,6 +6,6 @@ def subscriptions end def from_date - 1.week.ago.to_date + 8.days.ago.to_date end end diff --git a/spec/jobs/send_daily_alert_email_job_spec.rb b/spec/jobs/send_daily_alert_email_job_spec.rb index 86db8c064e..4d245a22d6 100644 --- a/spec/jobs/send_daily_alert_email_job_spec.rb +++ b/spec/jobs/send_daily_alert_email_job_spec.rb @@ -69,7 +69,7 @@ let(:job) { described_class.new } it "gets vacancies in the last day" do - expect(subscription).to receive(:vacancies_for_range).with(Time.zone.yesterday, Date.current) { Vacancy.none } + expect(subscription).to receive(:vacancies_for_range).with(2.days.ago.to_date, Date.yesterday) { Vacancy.none } job.vacancies_for_subscription(subscription) end end diff --git a/spec/jobs/send_weekly_alert_email_job_spec.rb b/spec/jobs/send_weekly_alert_email_job_spec.rb index 5b576e473e..1aef67e624 100644 --- a/spec/jobs/send_weekly_alert_email_job_spec.rb +++ b/spec/jobs/send_weekly_alert_email_job_spec.rb @@ -69,7 +69,7 @@ let(:job) { described_class.new } it "gets vacancies in the last week" do - expect(subscription).to receive(:vacancies_for_range).with(1.week.ago.to_date, Date.current) { Vacancy.none } + expect(subscription).to receive(:vacancies_for_range).with(8.days.ago.to_date, Date.yesterday) { Vacancy.none } job.vacancies_for_subscription(subscription) end end From 273ef9b169d76e83f025c26d7ead42eb397bfa6e Mon Sep 17 00:00:00 2001 From: starswan Date: Tue, 7 Jan 2025 15:52:50 +0000 Subject: [PATCH 2/5] enable emails --- terraform/workspace-variables/review_app_env.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/workspace-variables/review_app_env.yml b/terraform/workspace-variables/review_app_env.yml index 158be032a6..7d3ee64f74 100644 --- a/terraform/workspace-variables/review_app_env.yml +++ b/terraform/workspace-variables/review_app_env.yml @@ -6,7 +6,7 @@ BIGQUERY_DATASET: staging_dataset DFE_SIGN_IN_REGISTRATION_URL: https://test-profile.signin.education.gov.uk/register DISABLE_DATABASE_ENVIRONMENT_CHECK: 1 DISABLE_EMAILS: false -DISABLE_EXPENSIVE_JOBS: true +DISABLE_EXPENSIVE_JOBS: false ENFORCE_LOCAL_AUTHORITY_ALLOWLIST: false RAILS_ENV: production RAILS_LOG_TO_STDOUT: true From 02b6f0340812f6eb103b5deb0cb2c2be0d3ecb9d Mon Sep 17 00:00:00 2001 From: starswan Date: Tue, 7 Jan 2025 15:56:13 +0000 Subject: [PATCH 3/5] re-schedule emails for 16:15 --- config/schedule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/schedule.yml b/config/schedule.yml index 263a632ecc..1afbd75ed0 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -51,7 +51,7 @@ queue_applications_received: queue: default queue_daily_alerts: - cron: '0 15 * * *' + cron: '15 16 * * *' class: 'SendDailyAlertEmailJob' queue: default From e7209d24d2485ac63e8e5296ade32cac10db812b Mon Sep 17 00:00:00 2001 From: starswan Date: Tue, 7 Jan 2025 16:16:51 +0000 Subject: [PATCH 4/5] daily alerts 16:30 --- config/schedule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/schedule.yml b/config/schedule.yml index 1afbd75ed0..b691e104d7 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -51,7 +51,7 @@ queue_applications_received: queue: default queue_daily_alerts: - cron: '15 16 * * *' + cron: '30 16 * * *' class: 'SendDailyAlertEmailJob' queue: default From 1f860fd93d1552c7972d66e4722986d75b394f46 Mon Sep 17 00:00:00 2001 From: starswan Date: Tue, 7 Jan 2025 16:25:19 +0000 Subject: [PATCH 5/5] re-schedule for 8:30am as new alerts will only show up tomorrow for todays vacancies --- config/schedule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/schedule.yml b/config/schedule.yml index b691e104d7..7426fceb04 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -51,7 +51,7 @@ queue_applications_received: queue: default queue_daily_alerts: - cron: '30 16 * * *' + cron: '30 08 * * *' class: 'SendDailyAlertEmailJob' queue: default