Skip to content

Commit dfda861

Browse files
committed
Add job to schedule job to send bounce notifications
We want the job that sends bounce notifications to run on a schedule every day, and we want it to be retryable if it fails. Add a job that will run on a schdedule to enqueue the SendBounceNotificationsJob to send bounce notifications for the previous day so that retrying the job will send bounces for that day.
1 parent 9166003 commit dfda861

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class ScheduleBounceNotificationsJob < ApplicationJob
2+
queue_as :bounce_notifications
3+
4+
def perform
5+
CloudWatchService.record_job_started_metric(self.class.name)
6+
CurrentJobLoggingAttributes.job_class = self.class.name
7+
CurrentJobLoggingAttributes.job_id = job_id
8+
9+
SendBounceNotificationsJob.perform_later(bounced_on_date: Time.zone.yesterday.to_date)
10+
end
11+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "rails_helper"
2+
3+
RSpec.describe ScheduleBounceNotificationsJob do
4+
it "schedules a SendBounceNotifications job with yesterday's date" do
5+
expect(SendBounceNotificationsJob).to receive(:perform_later).with(bounced_on_date: Time.zone.yesterday.to_date)
6+
7+
described_class.perform_now
8+
end
9+
end

0 commit comments

Comments
 (0)