-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1391: Automate data retention and weekly report jobs
The `template-infra` v0.12.2 release contains built-in cron job support - just in time, too. Let's give it a shot with our data retention and weekly report jobs.
- Loading branch information
Showing
2 changed files
with
20 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace :weekly_reports do | ||
desc "Send weekly reports (NYC and later others?)" | ||
task send_all: :environment do | ||
report_date = Time.now.in_time_zone("America/New_York").beginning_of_week | ||
|
||
WeeklyReportMailer | ||
.with(site_id: "nyc", report_date: report_date.to_date) | ||
.report_email | ||
.deliver_now | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
locals { | ||
# The `cron` here is the literal name of the scheduled job. It can be anything you want. | ||
# For example "file_upload_jobs" or "daily_report". Whatever makes sense for your use case. | ||
# The `task_command` is what you want your scheduled job to run, for example: ["poetry", "run", "flask"]. | ||
# Schedule expression defines the frequency at which the job should run. | ||
# The syntax for `schedule_expression` is explained in the following documentation: | ||
# https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-scheduled-rule-pattern.html | ||
scheduled_jobs = { | ||
# cron = { | ||
# task_command = ["python", "-m", "flask", "--app", "app.py", "cron"] | ||
# schedule_expression = "cron(0 * ? * * *)" | ||
# } | ||
send_weekly_reports = { | ||
task_command = ["bin/rails", "weekly_reports:send_all"] | ||
schedule_expression = "cron(0 12 ? * MON *)" # Every Monday at 12pm UTC (7am EST / 8am EDT) | ||
} | ||
|
||
redact_data = { | ||
task_command = ["bin/rails", "data_deletion:redact_all"] | ||
schedule_expression = "cron(0 14 ? * * *)" # Every day at 2pm UTC (9am EST / 10am EDT) | ||
} | ||
} | ||
} |