Fix games stats, show all played games instead of top 10
This commit is contained in:
parent
637e3e6493
commit
89d1bbdd9e
|
@ -46,7 +46,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="px-2 sm:px-4 md:px-6 md:py-2">Games ({{ year }})</td>
|
<td class="px-2 sm:px-4 md:px-6 md:py-2">Games ({{ year }})</td>
|
||||||
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">{{ total_2023_games }}</td>
|
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">{{ total_year_games }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% if all_finished_this_year_count %}
|
{% if all_finished_this_year_count %}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -148,7 +148,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<h1 class="text-5xl text-center my-6">Top games by playtime</h1>
|
<h1 class="text-5xl text-center my-6">Games by playtime</h1>
|
||||||
<table class="responsive-table">
|
<table class="responsive-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -187,7 +187,7 @@ def stats_alltime(request: HttpRequest) -> HttpResponse:
|
||||||
"total_hours": format_duration(
|
"total_hours": format_duration(
|
||||||
this_year_sessions.total_duration_unformatted(), "%2.0H"
|
this_year_sessions.total_duration_unformatted(), "%2.0H"
|
||||||
),
|
),
|
||||||
"total_2023_games": this_year_played_purchases.all().count(),
|
"total_year_games": this_year_played_purchases.all().count(),
|
||||||
"top_10_games_by_playtime": top_10_games_by_playtime,
|
"top_10_games_by_playtime": top_10_games_by_playtime,
|
||||||
"year": year,
|
"year": year,
|
||||||
"total_playtime_per_platform": total_playtime_per_platform,
|
"total_playtime_per_platform": total_playtime_per_platform,
|
||||||
|
@ -287,6 +287,10 @@ def stats(request: HttpRequest, year: int = 0) -> HttpResponse:
|
||||||
games__sessions__in=this_year_sessions
|
games__sessions__in=this_year_sessions
|
||||||
).distinct()
|
).distinct()
|
||||||
|
|
||||||
|
this_year_played_games = Game.objects.filter(
|
||||||
|
sessions__in=this_year_sessions
|
||||||
|
).distinct()
|
||||||
|
|
||||||
this_year_purchases = Purchase.objects.filter(date_purchased__year=year)
|
this_year_purchases = Purchase.objects.filter(date_purchased__year=year)
|
||||||
this_year_purchases_with_currency = this_year_purchases.prefetch_related("games")
|
this_year_purchases_with_currency = this_year_purchases.prefetch_related("games")
|
||||||
this_year_purchases_without_refunded = this_year_purchases_with_currency.filter(
|
this_year_purchases_without_refunded = this_year_purchases_with_currency.filter(
|
||||||
|
@ -362,7 +366,7 @@ def stats(request: HttpRequest, year: int = 0) -> HttpResponse:
|
||||||
.order_by("-session_average")
|
.order_by("-session_average")
|
||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
top_10_games_by_playtime = games_with_playtime.order_by("-total_playtime")[:10]
|
top_10_games_by_playtime = games_with_playtime.order_by("-total_playtime")
|
||||||
for game in top_10_games_by_playtime:
|
for game in top_10_games_by_playtime:
|
||||||
game["formatted_playtime"] = format_duration(game["total_playtime"], "%2.0H")
|
game["formatted_playtime"] = format_duration(game["total_playtime"], "%2.0H")
|
||||||
|
|
||||||
|
@ -406,8 +410,8 @@ def stats(request: HttpRequest, year: int = 0) -> HttpResponse:
|
||||||
"total_hours": format_duration(
|
"total_hours": format_duration(
|
||||||
this_year_sessions.total_duration_unformatted(), "%2.0H"
|
this_year_sessions.total_duration_unformatted(), "%2.0H"
|
||||||
),
|
),
|
||||||
"total_games": this_year_played_purchases.count(),
|
"total_games": this_year_played_games.count(),
|
||||||
"total_2023_games": this_year_played_purchases.filter(
|
"total_year_games": this_year_played_purchases.filter(
|
||||||
games__year_released=year
|
games__year_released=year
|
||||||
).count(),
|
).count(),
|
||||||
"top_10_games_by_playtime": top_10_games_by_playtime,
|
"top_10_games_by_playtime": top_10_games_by_playtime,
|
||||||
|
|
Loading…
Reference in New Issue