Skip to content

Add job to schedule weekly deliveries#1978

Merged
stephencdaly merged 6 commits intomainfrom
add-job-to-schedule-weekly-deliveries
Mar 19, 2026
Merged

Add job to schedule weekly deliveries#1978
stephencdaly merged 6 commits intomainfrom
add-job-to-schedule-weekly-deliveries

Conversation

@stephencdaly
Copy link
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/BKWLt0FV

Add a recurring job that will run every Monday at 2:15am to created Delivery records and schedule SendSubmissionBatchJobs to send emails containing weekly batches of submissions per form and mode for the previous week for forms that have send_weekly_submission_batch set to true.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

Rename this class so we can use it for getting submissions for both
daily and weekly batch deliveries.
We will add a separate method to get weekly batches, so rename the
existing method.
Use the `.all_week` method to get the date range for the week,
ensuring it is in the London timezone. For now, a week for batching
will always start at the beginning of the day on a Monday. If this
later becomes configurable, we will need to update this
implementation.
Add a method, that given a date, will return batches of submissions
per form and mode where the form has `send_weekly_submission_batch`
set to true for the final submission in the week.

Include all submissions for the week in the batch, even if they were
submitted for an older version of the form that did not have
`send_weekly_submission_batch` set to true.
@stephencdaly stephencdaly force-pushed the add-job-to-schedule-weekly-deliveries branch from eafde96 to f0ffd44 Compare March 19, 2026 12:33
theseanything
theseanything previously approved these changes Mar 19, 2026
Add a job that will be run on a recurring schedule that finds all
form_ids and modes to send submission batches for the previous week.

For each form_id and mode, create a Delivery, associating the
submissions with it, and schedule a SendSubmissionBatchJob to send
the email.
Schedule the job to run every Monday at 2:15 AM London time. We tell
users that we will run the job shortly after 2:00 AM.

We're scheduling it to run a little while after the job to schedule
the daily batches has run in order to spread the load on the system.
@sonarqubecloud
Copy link

@github-actions
Copy link
Contributor

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-1978.submit.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

@stephencdaly stephencdaly added this pull request to the merge queue Mar 19, 2026
Merged via the queue into main with commit e750a29 Mar 19, 2026
5 checks passed
@stephencdaly stephencdaly deleted the add-job-to-schedule-weekly-deliveries branch March 19, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants