Skip to content

Commit

Permalink
added partial last sub time that is impossible to debug with db data …
Browse files Browse the repository at this point in the history
…(will test at home)
  • Loading branch information
JasonLovesDoggo committed Apr 4, 2024
1 parent 2e41557 commit feaf704
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gameserver/api/routes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.db.models import F
from django.db.models import F, OuterRef, Subquery
from gameserver.models.cache import ContestScore
from gameserver.models.contest import ContestProblem
from gameserver.models.contest import ContestProblem, ContestSubmission
from ninja import NinjaAPI, Schema
from typing import List
from typing import List, Any

def unicode_safe(string):
return string.encode("unicode_escape").decode()
Expand All @@ -13,14 +13,18 @@ class CTFSchema(Schema):
pos: int
team: str
score: int
lastAccept: Any

class CTFTimeSchema(Schema):
standings: List[CTFSchema]
tasks: List[str]

@api.get("/ctftime", response=CTFTimeSchema)
def add(request, contest_id: int):
standings = ContestScore.ranks(contest=contest_id).annotate(pos=F("rank"), score=F("points"), team=F("participation__team__name"))
last_sub_time = ContestSubmission.objects.filter(
participation=OuterRef("pk"), submission__is_correct=True
).values("submission__date_created")
standings = ContestScore.ranks(contest=contest_id).annotate(pos=F("rank"), score=F("points"), team=F("participation__team__name"), lastAccept=Subquery(last_sub_time))
# .only("pos", "team", "score")
task_names = ContestProblem.objects.filter(contest_id=contest_id).prefetch_related("problem__name").values_list("problem__name")

Expand Down

0 comments on commit feaf704

Please sign in to comment.