hotfix for command recompute_scoreboard

This commit is contained in:
Danhia 2022-01-31 18:46:34 +01:00
parent 396d8ee99b
commit c38cc8dc94
1 changed files with 1 additions and 8 deletions

View File

@ -7,12 +7,11 @@ class Command(BaseCommand):
help = 'Recomputes the score and ranking caches from the solutions' help = 'Recomputes the score and ranking caches from the solutions'
def handle(self, *args, **options): def handle(self, *args, **options):
all_sols = ex_models.CTF_flags.objects.select_related().all() all_sols = ex_models.CTF_flags.objects.select_related().filter(ctf__event=None)
scores = defaultdict(int) scores = defaultdict(int)
for sol in all_sols: for sol in all_sols:
scores[sol.user] += sol.ctf.points scores[sol.user] += sol.ctf.points
li = [(s, u) for (u, s) in scores.items()] li = [(s, u) for (u, s) in scores.items()]
# #li.sort(reverse=True)
li2 = [] li2 = []
old_rank = None old_rank = None
@ -29,10 +28,4 @@ class Command(BaseCommand):
for (u, s, r) in li2: for (u, s, r) in li2:
u.userprofileinfo.score = s u.userprofileinfo.score = s
# u.userprofileinfo.rank = r
u.userprofileinfo.save() u.userprofileinfo.save()
# not_handled = acc_models.UserProfileInfo.objects.exclude(
# id__in=[u.id for u, s, r in li2]
# )
# not_handled.update(score=0, rank=rank+1)