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