Skip to content

Commit

Permalink
Optimized potential fix for last accepted submission.
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Cameron <git@jasoncameron.dev>
  • Loading branch information
JasonLovesDoggo committed Apr 15, 2024
1 parent 7f12d3a commit cced0a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gameserver/api/routes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from typing import Any, List

from django.db.models import F, OuterRef, Subquery
from django.db.models import F, OuterRef, Max
from django.shortcuts import get_object_or_404
from ninja import NinjaAPI, Schema

Expand Down Expand Up @@ -67,14 +67,14 @@ def ctftime_standings(request, contest_name: str):
pos=F("rank"),
score=F("points"),
team=F("participation__team__name"),
lastAccept=Max("participation__submission__submission__date_created"),
# team=Coalesce(F("participation__team__name"), F("participation__participants__username")),
# Using Coalesce and indexing
# team=Case(
# When(F("participation__team__isnull")==True, then=Q(("participation__participants")[0]["username"])),
# default=F("team_name"),
# output_field=TextField(),
# ),
lastAccept=Subquery(last_sub_time),
)
.values("pos", "score", "team", "lastAccept")
)
Expand Down

0 comments on commit cced0a4

Please sign in to comment.