Limit stats of single year correctly
This commit is contained in:
		| @ -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 | ||||
|  | ||||
| ### New | ||||
|  | ||||
| @ -232,7 +232,10 @@ def list_sessions( | ||||
|  | ||||
| def stats(request, year: int): | ||||
|     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_with_playtime = year_purchases.annotate( | ||||
|         total_playtime=Sum( | ||||
|  | ||||
		Reference in New Issue
	
	Block a user