Skip to content

Commit

Permalink
Merge branch 'bugfix/contest-timecut'
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoleoncio committed Oct 4, 2024
1 parent fd28e88 commit 89112c5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contests/handlers/contest.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -120,11 +120,12 @@ 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),
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'),
Expand Down

0 comments on commit 89112c5

Please sign in to comment.