Skip to content

Commit

Permalink
Fix cron for last day of the month (#3831)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Klopper <[email protected]>
Co-authored-by: stephanie0x00 <[email protected]>
  • Loading branch information
3 people authored Nov 21, 2024
1 parent 1a0299d commit 36e3f7b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions rocky/reports/templates/partials/export_report_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ <h2>{% translate "Report schedule" %}</h2>
{% include "partials/form/fieldset.html" with fields=report_schedule_form_recurrence_choice %}

{% if is_scheduled_report %}
<p>
{% blocktranslate trimmed %}
Please choose a start date, time and recurrence for scheduling your report(s).
If you select a date on the 28th-31st of the month, it will always be scheduled on the last day of the month.
{% endblocktranslate %}
</p>
<p>
{% blocktranslate trimmed %}
The date you select will be the reference date for the data set for your report.
Expand Down
7 changes: 7 additions & 0 deletions rocky/rocky/locale/django.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3717,6 +3717,13 @@ msgid ""
"single occasion, select the one-time option."
msgstr ""

#: reports/templates/partials/export_report_settings.html
msgid ""
"Please choose a start date, time and recurrence for scheduling your "
"report(s). If you select a date on the 28th-31st of the month, it will "
"always be scheduled on the last day of the month."
msgstr ""

#: reports/templates/partials/export_report_settings.html
msgid ""
"The date you select will be the reference date for the data set for your "
Expand Down
4 changes: 2 additions & 2 deletions rocky/rocky/views/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ def convert_recurrence_to_cron_expressions(self, recurrence: str, start_date_tim
# Recurres every year on the {day} of the {month} at the selected time
}

if 28 <= day <= 31:
cron_expr["monthly"] = f"{minute} {hour} 28-31 * *"
if day >= 28:
cron_expr["monthly"] = f"{minute} {hour} L * *"
else:
cron_expr["monthly"] = (
f"{minute} {hour} {day} * *" # Recurres on the exact {day} of the month at the selected time
Expand Down

0 comments on commit 36e3f7b

Please sign in to comment.