From 34d8432fa8bea1ecaaf3c58950a590907abe2021 Mon Sep 17 00:00:00 2001 From: starswan Date: Thu, 19 Dec 2024 14:45:05 +0000 Subject: [PATCH] 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