Display only games with >2 hours of playtime on stats page #81

Closed
opened 2025-01-29 11:45:14 +00:00 by lukas · 1 comment
Owner

Something like this:

json_dumps(
    list(
        Game.objects.filter(edition__purchase__session__timestamp_start__year=2024)
        .annotate(
            total_playtime=Sum(
                F("edition__purchase__session__duration_calculated")
                + F("edition__purchase__session__duration_manual"),
                output_field=DurationField(),
            ),
            total_playtime_hours=ExpressionWrapper(
                F("total_playtime") / timedelta(hours=1), output_field=IntegerField()
            ),
        )
        .values("name", "total_playtime_hours")
        .filter(total_playtime__gt=timedelta(hours=2))
        .order_by("-total_playtime_hours")
    )
)
Something like this: ```py json_dumps( list( Game.objects.filter(edition__purchase__session__timestamp_start__year=2024) .annotate( total_playtime=Sum( F("edition__purchase__session__duration_calculated") + F("edition__purchase__session__duration_manual"), output_field=DurationField(), ), total_playtime_hours=ExpressionWrapper( F("total_playtime") / timedelta(hours=1), output_field=IntegerField() ), ) .values("name", "total_playtime_hours") .filter(total_playtime__gt=timedelta(hours=2)) .order_by("-total_playtime_hours") ) ) ```
Author
Owner

This issue has become outdated, the stats page will probably only display a top X entries so it doesn't make sense to implement this

This issue has become outdated, the stats page will probably only display a top X entries so it doesn't make sense to implement this
lukas closed this issue 2026-06-07 19:23:07 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lukas/timetracker#81