From 1c996a79dbdbfa7a7746859c31cb412355f8fe4a Mon Sep 17 00:00:00 2001 From: albertoleoncio Date: Fri, 4 Oct 2024 14:12:08 -0300 Subject: [PATCH] Merge branch 'bugfix/contest-timecut' --- contests/handlers/contest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contests/handlers/contest.py b/contests/handlers/contest.py index db80732..dfb0898 100644 --- a/contests/handlers/contest.py +++ b/contests/handlers/contest.py @@ -1,5 +1,5 @@ import requests -from datetime import timedelta +from datetime import timedelta, datetime, timezone from django.db.models import Count, Sum, Subquery, OuterRef, Case, When, Q from django.db.models.functions import TruncDay from contests.models import Evaluator, Edit, Participant, Qualification, Article @@ -120,11 +120,13 @@ def count_articles(self, contest): return len(list_) def edits_summary(self, contest): + timecut = datetime(2024, 10, 1, tzinfo=timezone.utc) edits_summary = ( Edit.objects.filter(contest=contest) .aggregate( new_pages=Sum(Case(When(new_page=True, then=1), default=0)), - edited_articles=Count('article', distinct=True), + edited_articles=Count('article', filter=Q(participant__isnull=False) & Q(contest__start_time__gt=timecut) | Q(contest__start_time__lte=timecut), distinct=True), + edited_articles_participant=Count('article', filter=Q(participant__isnull=False), distinct=True), valid_edits=Sum(Case(When(last_evaluation__valid_edit=True, then=1), default=0)), all_bytes=Sum(Case( When(last_evaluation__valid_edit=True, then='last_evaluation__real_bytes'),