Skip to content

Commit

Permalink
add sorting cronified tasks order test on frequency (nb of occurs in …
Browse files Browse the repository at this point in the history
…a year) > hour > minute, PLUS reorder tasks in cron.json"
  • Loading branch information
vincentporte committed Mar 5, 2025
1 parent 99e0b66 commit fe3e4b2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
14 changes: 7 additions & 7 deletions clevercloud/cron.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[
"*/10 * * * * $ROOT/clevercloud/rebuild_index.sh",
"*/15 7-21 * * * $ROOT/clevercloud/run_management_command.sh send_messages_notifications asap",
"10 6-22 * * * $ROOT/clevercloud/run_management_command.sh add_user_to_list_when_register",
"55 8-18 * * 1-5 $ROOT/clevercloud/run_management_command.sh add_missyou_notifications",
"0 3 * * * $ROOT/clevercloud/run_management_command.sh clearsessions",
"20 6 * * * $ROOT/clevercloud/run_management_command.sh send_messages_notifications day",
"0 11 * * * $ROOT/clevercloud/run_management_command.sh collect_matomo_stats",
"5 11 * * * $ROOT/clevercloud/run_management_command.sh collect_django_stats",
"10 11 1 * * $ROOT/clevercloud/run_management_command.sh collect_matomo_stats --period month",
"2 12 * * * $ROOT/clevercloud/run_management_command.sh datas_anonymisation",
"30 13 * * 1-5 $ROOT/clevercloud/run_management_command.sh send_notifs_on_unanswered_topics",
"15 11 * * 1 $ROOT/clevercloud/run_management_command.sh collect_matomo_forum_stats",
"*/15 7-21 * * * $ROOT/clevercloud/run_management_command.sh send_messages_notifications asap",
"55 8-18 * * 1-5 $ROOT/clevercloud/run_management_command.sh add_missyou_notifications",
"20 6 * * * $ROOT/clevercloud/run_management_command.sh send_messages_notifications day",
"10 6-22 * * * $ROOT/clevercloud/run_management_command.sh add_user_to_list_when_register",
"0 12 * * 1 $ROOT/clevercloud/run_management_command.sh delete_old_email_sent_tracks",
"2 12 * * * $ROOT/clevercloud/run_management_command.sh datas_anonymisation",
"30 13 * * 1-5 $ROOT/clevercloud/run_management_command.sh send_notifs_on_unanswered_topics"
"10 11 1 * * $ROOT/clevercloud/run_management_command.sh collect_matomo_stats --period month"
]
17 changes: 17 additions & 0 deletions lacommunaute/utils/tests/tests_consistency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import json
import pathlib

from crontab import CronTab


def test_crontab_order(settings):
current_jobs = list(
CronTab(
tab="\n".join(
json.loads(pathlib.Path(settings.ROOT_DIR).joinpath("clevercloud", "cron.json").read_bytes())
)
)
)
ordered_jobs = sorted(current_jobs, key=lambda j: (-j.frequency(), j.hour.parts, j.minute.parts))

assert ordered_jobs == current_jobs

0 comments on commit fe3e4b2

Please sign in to comment.