Limit stats of single year correctly
This commit is contained in:
parent
df5e605582
commit
0130ab0059
|
@ -1,3 +1,8 @@
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* Correctly limit sessions to a single year for stats
|
||||||
|
|
||||||
## 1.2.0 / 2023-11-01 20:18+01:00
|
## 1.2.0 / 2023-11-01 20:18+01:00
|
||||||
|
|
||||||
### New
|
### New
|
||||||
|
|
|
@ -232,7 +232,10 @@ def list_sessions(
|
||||||
|
|
||||||
def stats(request, year: int):
|
def stats(request, year: int):
|
||||||
first_day_of_year = datetime(year, 1, 1)
|
first_day_of_year = datetime(year, 1, 1)
|
||||||
year_sessions = Session.objects.filter(timestamp_start__gte=first_day_of_year)
|
last_day_of_year = datetime(year + 1, 1, 1)
|
||||||
|
year_sessions = Session.objects.filter(
|
||||||
|
timestamp_start__gte=first_day_of_year
|
||||||
|
).filter(timestamp_start__lt=last_day_of_year)
|
||||||
year_purchases = Purchase.objects.filter(session__in=year_sessions).distinct()
|
year_purchases = Purchase.objects.filter(session__in=year_sessions).distinct()
|
||||||
year_purchases_with_playtime = year_purchases.annotate(
|
year_purchases_with_playtime = year_purchases.annotate(
|
||||||
total_playtime=Sum(
|
total_playtime=Sum(
|
||||||
|
|
Loading…
Reference in New Issue