Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions misc/management/commands/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from scoring.jobs import (
finalize_leaderboards,
update_global_comment_and_question_leaderboards,
update_gobal_bot_leaderboard,
)
from scoring.utils import update_medal_points_and_ranks

Expand Down Expand Up @@ -200,6 +201,13 @@ def handle(self, *args, **options):
max_instances=1,
replace_existing=True,
)
scheduler.add_job(
close_old_connections(update_gobal_bot_leaderboard),
trigger=CronTrigger.from_crontab("0 5 * * *"), # Every day at 05:00 UTC
id="update_gobal_bot_leaderboard",
max_instances=1,
replace_existing=True,
)

#
# Comment Jobs
Expand Down
17 changes: 17 additions & 0 deletions scoring/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,26 @@
from scoring.models import Leaderboard
from scoring.utils import update_project_leaderboard

from scoring.management.commands.update_global_bot_leaderboard import (
run_update_global_bot_leaderboard,
)

logger = logging.getLogger(__name__)


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}")


def update_global_comment_and_question_leaderboards():
global_leaderboards = Leaderboard.objects.filter(
finalized=False,
Expand Down
Loading