fix(daily-challenge): fix don't calculate user's statistics

This commit is contained in:
MingxuanGame
2025-08-29 16:19:37 +08:00
committed by GitHub
parent 224e890e31
commit d38cf12826

View File

@@ -138,8 +138,8 @@ async def process_daily_challenge_top():
) )
) )
).first() ).first()
if room is None: participated_users = []
return if room is not None:
scores = ( scores = (
await session.exec( await session.exec(
select(PlaylistBestScore) select(PlaylistBestScore)
@@ -153,11 +153,10 @@ async def process_daily_challenge_top():
).all() ).all()
total_score_count = len(scores) total_score_count = len(scores)
s = [] s = []
participated_users = []
for i, score in enumerate(scores): for i, score in enumerate(scores):
stats = await session.get(DailyChallengeStats, score.user_id) stats = await session.get(DailyChallengeStats, score.user_id)
if stats is None: # not execute if stats is None: # not execute
return continue
if stats.last_update is None or stats.last_update.replace(tzinfo=UTC).date() != now.date(): if stats.last_update is None or stats.last_update.replace(tzinfo=UTC).date() != now.date():
if total_score_count < 10 or ceil(i + 1 / total_score_count) <= 0.1: if total_score_count < 10 or ceil(i + 1 / total_score_count) <= 0.1:
stats.top_10p_placements += 1 stats.top_10p_placements += 1
@@ -173,7 +172,7 @@ async def process_daily_challenge_top():
for id in user_ids: for id in user_ids:
stats = await session.get(DailyChallengeStats, id) stats = await session.get(DailyChallengeStats, id)
if stats is None: # not execute if stats is None: # not execute
return continue
stats.daily_streak_current = 0 stats.daily_streak_current = 0
if stats.last_weekly_streak and not are_same_weeks( if stats.last_weekly_streak and not are_same_weeks(
stats.last_weekly_streak.replace(tzinfo=UTC), now - timedelta(days=7) stats.last_weekly_streak.replace(tzinfo=UTC), now - timedelta(days=7)