fix(computescores): ensure rating processing order is the same as in export
This commit is contained in:
parent
a67cc96935
commit
353213b1c8
|
@ -1 +1 @@
|
|||
__version__ = "0.14.2"
|
||||
__version__ = "0.14.3"
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue