Fix playtime stats per year
This commit is contained in:
parent
abdcfdfe64
commit
ad0641f95b
@ -167,7 +167,7 @@
|
|||||||
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">
|
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">
|
||||||
<c-gamelink :game_id=game.id :name=game.name />
|
<c-gamelink :game_id=game.id :name=game.name />
|
||||||
</td>
|
</td>
|
||||||
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">{{ game.playtime | format_duration }}</td>
|
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">{{ game.total_playtime | format_duration }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -364,9 +364,16 @@ def stats(request: HttpRequest, year: int = 0) -> HttpResponse:
|
|||||||
)
|
)
|
||||||
total_spent = this_year_spendings["total_spent"] or 0
|
total_spent = this_year_spendings["total_spent"] or 0
|
||||||
|
|
||||||
games_with_playtime = Game.objects.filter(
|
games_with_playtime = (
|
||||||
sessions__in=this_year_sessions
|
Game.objects.filter(sessions__timestamp_start__year=year)
|
||||||
).distinct()
|
.annotate(
|
||||||
|
total_playtime=Sum(
|
||||||
|
F("sessions__duration_calculated"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.filter(total_playtime__gt=timedelta(0))
|
||||||
|
)
|
||||||
|
|
||||||
month_playtimes = (
|
month_playtimes = (
|
||||||
this_year_sessions.annotate(month=TruncMonth("timestamp_start"))
|
this_year_sessions.annotate(month=TruncMonth("timestamp_start"))
|
||||||
.values("month")
|
.values("month")
|
||||||
@ -380,7 +387,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("-playtime")
|
top_10_games_by_playtime = games_with_playtime.order_by("-total_playtime")
|
||||||
|
|
||||||
total_playtime_per_platform = (
|
total_playtime_per_platform = (
|
||||||
this_year_sessions.values("game__platform__name")
|
this_year_sessions.values("game__platform__name")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user