From d1cb0edf87b3df973b0f2082792789b608439a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Mon, 11 Nov 2024 00:06:45 +0100 Subject: [PATCH] Fix stats --- games/views/general.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/games/views/general.py b/games/views/general.py index ccafaf2..5686a6e 100644 --- a/games/views/general.py +++ b/games/views/general.py @@ -78,9 +78,7 @@ def stats_alltime(request: HttpRequest) -> HttpResponse: ).distinct() this_year_purchases = Purchase.objects.all() - this_year_purchases_with_currency = this_year_purchases.select_related( - "edition" - ).filter(price_currency__exact=selected_currency) + this_year_purchases_with_currency = this_year_purchases.select_related("edition") this_year_purchases_without_refunded = this_year_purchases_with_currency.filter( date_refunded=None ) @@ -124,7 +122,7 @@ def stats_alltime(request: HttpRequest) -> HttpResponse: ).order_by("date_finished") this_year_spendings = this_year_purchases_without_refunded.aggregate( - total_spent=Sum(F("price")) + total_spent=Sum(F("converted_price")) ) total_spent = this_year_spendings["total_spent"] or 0 @@ -301,8 +299,6 @@ def stats(request: HttpRequest, year: int = 0) -> HttpResponse: this_year_purchases = Purchase.objects.filter(date_purchased__year=year) this_year_purchases_with_currency = this_year_purchases.select_related("edition") - # fixme: add conversion table for currencies - # ).filter(price_currency__exact=selected_currency) this_year_purchases_without_refunded = this_year_purchases_with_currency.filter( date_refunded=None ) @@ -317,7 +313,7 @@ def stats(request: HttpRequest, year: int = 0) -> HttpResponse: this_year_purchases_unfinished = ( this_year_purchases_unfinished_dropped_nondropped.filter( date_dropped__isnull=True - ) + ).exclude(ownership_type=Purchase.DEMO) ) this_year_purchases_dropped = ( this_year_purchases_unfinished_dropped_nondropped.filter( @@ -348,7 +344,7 @@ def stats(request: HttpRequest, year: int = 0) -> HttpResponse: ).order_by("date_finished") this_year_spendings = this_year_purchases_without_refunded.aggregate( - total_spent=Sum(F("price")) + total_spent=Sum(F("converted_price")) ) total_spent = this_year_spendings["total_spent"] or 0