Skip to content

Commit

Permalink
Merge pull request #75 from clopedion/main
Browse files Browse the repository at this point in the history
leaderboard bugfix
  • Loading branch information
TheOriginalSoni authored Oct 30, 2024
2 parents 17b228b + fc8d205 commit ae660e1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions myus/myus/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django import urls
from django.contrib.auth.decorators import login_required
from django.db.models import OuterRef, Sum, Subquery, Count, Q, F
from django.db.models import OuterRef, Sum, Subquery, Count, Q, F, DurationField
from django.db.models.functions import Coalesce, Greatest
from django.http import Http404, JsonResponse
from django.http import HttpResponse
Expand Down Expand Up @@ -211,7 +211,9 @@ def leaderboard(request, hunt_id: int, slug: Optional[str] = None):
),
created_or_start=Greatest(F("creation_time"), hunt.start_time),
solve_time=Greatest(
Coalesce(F("last_solve"), F("created_or_start")) - F("created_or_start"), 0
Coalesce(F("last_solve"), F("created_or_start")) - F("created_or_start"),
0,
output_field=DurationField(),
),
)

Expand Down

0 comments on commit ae660e1

Please sign in to comment.