Skip to content

Commit

Permalink
Merge pull request #74 from clopedion/main
Browse files Browse the repository at this point in the history
Allow blank answer responses, make negative solve times 0
  • Loading branch information
TheOriginalSoni authored Oct 30, 2024
2 parents 23d2727 + 2fce3a4 commit 17b228b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
23 changes: 23 additions & 0 deletions myus/myus/migrations/0011_alter_puzzle_answer_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0.2 on 2024-10-30 11:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("myus", "0010_hunt_leaderboard_style_alter_hunt_end_time_and_more"),
]

operations = [
migrations.AlterField(
model_name="puzzle",
name="answer_response",
field=models.CharField(
blank=True,
default="",
help_text='Response to a correct answer. Default is "You have solved this puzzle!". Basic html and images allowed.',
max_length=500,
),
),
]
1 change: 1 addition & 0 deletions myus/myus/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class Puzzle(models.Model):
answer_response = models.CharField(
max_length=500,
default="",
blank=True,
help_text='Response to a correct answer. Default is "You have solved this puzzle!". Basic html and images allowed.',
)
points = models.IntegerField(
Expand Down
7 changes: 4 additions & 3 deletions myus/myus/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,14 @@ def leaderboard(request, hunt_id: int, slug: Optional[str] = None):
.values("time")
),
created_or_start=Greatest(F("creation_time"), hunt.start_time),
solve_time=Coalesce(F("last_solve"), F("created_or_start"))
- F("created_or_start"),
solve_time=Greatest(
Coalesce(F("last_solve"), F("created_or_start")) - F("created_or_start"), 0
),
)

# print(teams.query)
if hunt.leaderboard_style == Hunt.LeaderboardStyle.SPEEDRUN:
teams = teams.order_by("-score", "-solve_count", "solve_time")
teams = teams.order_by("-score", "-solve_count", "solve_time", "last_solve")
template = "leaderboard_SPD.html"
else:
teams = teams.order_by("-score", "-solve_count", "last_solve")
Expand Down

0 comments on commit 17b228b

Please sign in to comment.