Skip to content

Commit

Permalink
Merge pull request #106 from florczakraf/101-sorting-scores-by-date
Browse files Browse the repository at this point in the history
Add sorting scores by date
  • Loading branch information
florczakraf committed Jul 9, 2023
2 parents 7d9faab + f4ad8be commit d8b7e31
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions boogiestats/boogie_ui/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
path("songs_by_players/", views.SongsByPlayersListView.as_view(), name="songs_by_players"),
path("song_by_player/<str:song_hash>/<int:player_id>", views.SongByPlayerView.as_view(), name="song_by_player"),
path("songs/<str:song_hash>/", views.SongView.as_view(), name="song"),
path("song_by_date/<str:song_hash>/", views.SongByDateView.as_view(), name="song_by_date"),
path("songs/<str:song_hash>/highscores", views.SongHighscoresView.as_view(), name="song_highscores"),
path("scores/", views.ScoreListView.as_view(), name="scores"),
path("scores/<int:pk>/", views.ScoreView.as_view(), name="score"),
Expand Down
10 changes: 10 additions & 0 deletions boogiestats/boogie_ui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,16 @@ def get_queryset(self):
)


class SongByDateView(SongView):
def get_queryset(self):
song_hash = self.kwargs["song_hash"]
return (
Song.get_or_404(hash=song_hash)
.scores.order_by("-submission_date", "score")
.select_related("song", "player")
)


class ScoreView(generic.DetailView):
template_name = "boogie_ui/score.html"
model = Score
Expand Down
2 changes: 1 addition & 1 deletion boogiestats/templates/boogie_ui/score_with_judgments.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<a href="{% url "score" pk=score.id %}">
<div>{{ score.score|div:100|stringformat:".2f" }}%</div>
</a>
<div class="score-box"
<div class="score-box mx-auto"
style="grid-template-columns: {{ score.fantastics_plus }}fr {{ score.fantastics }}fr {{ score.excellents }}fr {{ score.greats }}fr {{ score.decents }}fr {{ score.way_offs }}fr {{ score.misses }}fr">
<div class="fantastic"></div>
<div class="fantastic_white"></div>
Expand Down
26 changes: 23 additions & 3 deletions boogiestats/templates/boogie_ui/song.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<h2 class="mt-2">{% include "boogie_ui/song_display_name.html" %}</h2>
<p>Pack: {{ song.chart_info.pack_name }}</p>
<a href="{% url "song" song_hash=song.hash %}"
class="btn {% if request.resolver_match.url_name == "song" %}btn-success{% else %}btn-secondary{% endif %}">
class="btn {% if request.resolver_match.url_name in "song,song_by_date" %}btn-success{% else %}btn-secondary{% endif %}">
All Scores ({{ song.scores.count }})
</a>
<a href="{% url "song_highscores" song_hash=song.hash %}"
Expand Down Expand Up @@ -48,10 +48,30 @@ <h3>
<table class="table table-striped">
<thead class="bg-body-secondary">
<tr>
<th scope="col" class="w-1 text-nowrap">ITG Score ↓</th>
<th scope="col" class="w-1 text-nowrap">
{% if request.resolver_match.url_name == "song_highscores" %}
ITG Highscore ↓
{% elif request.resolver_match.url_name in "song,song_by_date" %}
<a href="{% url "song" song_hash=song.hash %}">
ITG Score
{% if request.resolver_match.url_name == "song" %}↓{% endif %}
</a>
{% else %}
ITG Score ↓
{% endif %}
</th>
<th scope="col" class="w-1 text-nowrap">Player</th>
<th scope="col" class="w-100 text-nowrap">Comment</th>
<th scope="col" class="w-1 text-nowrap">Submission Date</th>
<th scope="col" class="w-1 text-nowrap">
{% if request.resolver_match.url_name in "song,song_by_date" %}
<a href="{% url "song_by_date" song_hash=song.hash %}">
Submission Date
{% if request.resolver_match.url_name == "song_by_date" %}↓{% endif %}
</a>
{% else %}
Submission Date
{% endif %}
</th>
</tr>
</thead>
<tbody class="align-middle">
Expand Down

0 comments on commit d8b7e31

Please sign in to comment.