-
Notifications
You must be signed in to change notification settings - Fork 27
adds daily task to update global bot leaderboard, refactors command for convenience #3933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f5a2b07
4d2c0f7
55af6c6
e9eeda9
e531fac
fb932d9
fd22289
d1e4f96
33ebff2
fb72e11
b7714cb
d190391
64d2d7b
1ae0a4b
ff1ce67
d351534
a0c679e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,9 +10,26 @@ | |||||||||||||||||||||||||||||||||
| from scoring.tasks import update_custom_leaderboard | ||||||||||||||||||||||||||||||||||
| from scoring.tasks import update_coherence_spring_2026_cup | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| from scoring.management.commands.update_global_bot_leaderboard import ( | ||||||||||||||||||||||||||||||||||
| run_update_global_bot_leaderboard, | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| logger = logging.getLogger(__name__) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| def update_gobal_bot_leaderboard(): | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo in function name: The function name has a typo ("gobal" vs "global"). This typo propagates to the cron job ID and import. Fix this before it becomes a maintenance headache. ♻️ Proposed fix-def update_gobal_bot_leaderboard():
+def update_global_bot_leaderboard():Also update the import in 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| global_bot_leaderboard = Leaderboard.objects.filter( | ||||||||||||||||||||||||||||||||||
| name="Global Bot Leaderboard", | ||||||||||||||||||||||||||||||||||
| ).first() | ||||||||||||||||||||||||||||||||||
| if not global_bot_leaderboard: | ||||||||||||||||||||||||||||||||||
| logger.warning("Global Bot Leaderboard not found.") | ||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||
| run_update_global_bot_leaderboard() | ||||||||||||||||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||||||||||||||||
| logger.error(f"Error updating Global Bot Leaderboard: {e}") | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard is ineffective and Two issues:
Proposed fix def update_gobal_bot_leaderboard():
- global_bot_leaderboard = Leaderboard.objects.filter(
- name="Global Bot Leaderboard",
- ).first()
- if not global_bot_leaderboard:
- logger.warning("Global Bot Leaderboard not found.")
- return
try:
run_update_global_bot_leaderboard()
except Exception as e:
- logger.error(f"Error updating Global Bot Leaderboard: {e}")
+ logger.exception(f"Error updating Global Bot Leaderboard: {e}")If the guard is intentional (i.e., the job should only run when the leaderboard already exists), remove the 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.14.14)[warning] 29-29: Do not catch blind exception: (BLE001) [warning] 30-30: Use Replace with (TRY400) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| def update_global_comment_and_question_leaderboards(): | ||||||||||||||||||||||||||||||||||
| global_leaderboards = Leaderboard.objects.filter( | ||||||||||||||||||||||||||||||||||
| finalized=False, | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scheduling conflict: both
update_custom_leaderboardsandupdate_gobal_bot_leaderboardrun at 05:00 UTC.Both jobs are scheduled at the same time (lines 207 and 214). Since
update_gobal_bot_leaderboardtakes ~20 minutes as noted in the PR description, running them concurrently could cause resource contention. Consider staggering the times.♻️ Suggested fix - stagger to 06:00 UTC
scheduler.add_job( close_old_connections(update_gobal_bot_leaderboard), - trigger=CronTrigger.from_crontab("0 5 * * *"), # Every day at 05:00 UTC + trigger=CronTrigger.from_crontab("0 6 * * *"), # Every day at 06:00 UTC id="update_gobal_bot_leaderboard", max_instances=1, replace_existing=True, )📝 Committable suggestion
🤖 Prompt for AI Agents