Skip to content

Commit

Permalink
Optimized time_taken
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo authored Mar 6, 2024
1 parent 3393e9e commit 560eef6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions gameserver/models/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,10 @@ def last_solve_time(self):
return self.contest.start_time

@property
def time_taken(self):
def time_taken(self) -> str:
"""Returns the total amount of time the user has spent on the contest"""
solve_time = self.last_solve_time
return timedelta(seconds=round((solve_time - self.contest.start_time).total_seconds()))
return timedelta(seconds=round((solve_time - self.contest.start_time).strfdelta()))

def rank(self):
if isinstance(self.points, int):
Expand Down
2 changes: 1 addition & 1 deletion templates/contest/participation.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h2 class="card-header fs-6">Recent Submissions</h2>
<span>flag{{ participation.flags|pluralize }} captured</span>
</div>
<div>
<span>{{ participation.time_taken|strfdelta }}</span>
<span>{{ participation.time_taken }}</span>
<span>time taken</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/contest/scoreboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{% endif %}
<td>{{ participation.points }}</td>
<td>{{ participation.flags }}</td>
<td>{{ participation.time_taken|strfdelta }}</td>
<td>{{ participation.time_taken }}</td>
</tr>
{% endfor %}
{% endblock %}

0 comments on commit 560eef6

Please sign in to comment.