fix(computescores): ensure rating processing order is the same as in export
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Luca 2024-02-16 12:01:26 +01:00
parent a67cc96935
commit 353213b1c8
2 changed files with 16 additions and 9 deletions

View File

@ -1 +1 @@
__version__ = "0.14.2"
__version__ = "0.14.3"

View File

@ -1,6 +1,6 @@
import math
import statistics
from operator import itemgetter
from operator import attrgetter, itemgetter
from django.core.management.base import BaseCommand, CommandError
from django_scopes import scope
@ -31,12 +31,19 @@ class Command(BaseCommand):
with scope(event=event):
submissions = {}
for juror in event.jurors.prefetch_related("ratings"):
ratings = {
r.submission.code: int(r.rating)
for r in juror.ratings.exclude(rating="")
}
values = list(ratings.values())
for juror in event.jurors.prefetch_related("ratings__submission").order_by(
"token"
):
ratings = list(
juror.ratings.exclude(rating="").order_by("submission__created")
)
values = list(map(int, map(attrgetter("rating"), ratings)))
ratings = dict(
zip(
map(attrgetter("code"), map(attrgetter("submission"), ratings)),
values,
)
)
if len(values) < RATINGS_MIN:
mean = MEAN
@ -52,7 +59,7 @@ class Command(BaseCommand):
submissions[code] = []
submissions[code].append((ratings[code] - mean) / std * STD + MEAN)
for submission in Submission.objects.prefetch_related("score").filter(
for submission in Submission.objects.select_related("score").filter(
code__in=submissions.keys()
):
try: