drop leftovers from the live leaderboard: no fake model rows, no second sort

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-24 07:27:45 +03:30
parent ca6b2ff4c9
commit 81348cee5a
2 changed files with 11 additions and 21 deletions

View File

@@ -77,14 +77,8 @@ class Command(BaseCommand):
from progress.models import LeaderboardEntry
days = opts['days']
scores = self._collect(period, days, include_zero=opts['include_zero'])
if not opts['include_zero']:
scores = [(uid, xp) for uid, xp in scores if xp > 0]
# ترتیبِ قطعی: امتیازِ بیشتر جلوتر، و در تساوی user_id کوچک‌تر جلوتر —
# وگرنه دو اجرای پشت‌سرهم روی داده‌ی یکسان رتبه‌های متفاوت می‌دهند.
scores.sort(key=lambda p: (-p[1], p[0]))
scores = scores[:opts['limit']]
# مرتب‌سازی و کنار گذاشتنِ XPی صفر را خودِ compute_scores انجام می‌دهد.
scores = self._collect(period, days, include_zero=opts['include_zero'])[:opts['limit']]
label = period if period == 'all_time' else f'{period} ({days} روزِ اخیر)'
if opts['dry_run']: