Skip to content

Commit 2fe00e1

Browse files
committed
change command to task, add job, refactor scoring/utils functions for easier access
1 parent 47b0890 commit 2fe00e1

File tree

5 files changed

+246
-402
lines changed

5 files changed

+246
-402
lines changed

misc/management/commands/cron.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from scoring.jobs import (
2727
finalize_leaderboards,
2828
update_global_comment_and_question_leaderboards,
29+
update_custom_leaderboards,
2930
)
3031
from scoring.utils import update_medal_points_and_ranks
3132

@@ -200,6 +201,13 @@ def handle(self, *args, **options):
200201
max_instances=1,
201202
replace_existing=True,
202203
)
204+
scheduler.add_job(
205+
close_old_connections(update_custom_leaderboards),
206+
trigger=CronTrigger.from_crontab("0 5 * * *"), # Every day at 05:00 UTC
207+
id="update_custom_leaderboards",
208+
max_instances=1,
209+
replace_existing=True,
210+
)
203211

204212
#
205213
# Comment Jobs

scoring/jobs.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from scoring.constants import LeaderboardScoreTypes
66
from scoring.models import Leaderboard
77
from scoring.utils import update_project_leaderboard
8+
from scoring.tasks import update_custom_leaderboard
89

910
logger = logging.getLogger(__name__)
1011

@@ -30,3 +31,11 @@ def finalize_leaderboards():
3031
if finalize_time and finalize_time <= timezone.now():
3132
logger.info(f"Finalizing leaderboard: {leaderboard}")
3233
update_project_leaderboard(leaderboard=leaderboard)
34+
35+
36+
def update_custom_leaderboards():
37+
update_custom_leaderboard(
38+
project_id=1,
39+
minimum_time=None,
40+
spot_times=None,
41+
)

0 commit comments

Comments
 (0)