From ddc86c3b58eea2a6011ee8f870f896b1dcd63541 Mon Sep 17 00:00:00 2001 From: Jaimyn Mayer Date: Sun, 14 Jul 2024 01:36:31 +1000 Subject: [PATCH] minor bug fixes --- memberportal/api_member_bucks/views.py | 12 ++++++++---- memberportal/api_metrics/metrics.py | 3 ++- memberportal/api_metrics/views.py | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/memberportal/api_member_bucks/views.py b/memberportal/api_member_bucks/views.py index 13f5bea3..9bd1eb66 100644 --- a/memberportal/api_member_bucks/views.py +++ b/memberportal/api_member_bucks/views.py @@ -153,13 +153,17 @@ class GetMemberbucksBalanceList(APIView): permission_classes = (permissions.IsAdminUser | HasAPIKey,) def get(self, request): - total_balance = MemberBucks.objects.aggregate(Sum("amount")) - member_balances = Profile.objects.all().values( - "first_name", "last_name", "screen_name", "memberbucks_balance" + total_balance = Profile.objects.filter(memberbucks_balance__lt=1000).aggregate( + Sum("memberbucks_balance") + ) + member_balances = ( + Profile.objects.all() + .order_by("-memberbucks_balance") + .values("first_name", "last_name", "screen_name", "memberbucks_balance") ) return Response( { - "total_memberbucks": total_balance["amount__sum"], + "total_memberbucks": total_balance["memberbucks_balance__sum"], "member_balances": member_balances, }, status=status.HTTP_200_OK, diff --git a/memberportal/api_metrics/metrics.py b/memberportal/api_metrics/metrics.py index 76297709..693c3dd4 100644 --- a/memberportal/api_metrics/metrics.py +++ b/memberportal/api_metrics/metrics.py @@ -142,7 +142,8 @@ def calculate_memberbucks_transactions(): logger.debug("Calculating subscription count total") transaction_data = [] for transaction_type in ( - MemberBucks.objects.values("transaction_type") + MemberBucks.objects.filter(amount__lt=1000) + .values("transaction_type") .annotate(amount=Sum("amount")) .order_by("-amount") ): diff --git a/memberportal/api_metrics/views.py b/memberportal/api_metrics/views.py index 69aeafba..bbb5bfda 100644 --- a/memberportal/api_metrics/views.py +++ b/memberportal/api_metrics/views.py @@ -79,6 +79,8 @@ def put(self, request): api_metrics.calculate_memberbucks_balance() api_metrics.calculate_memberbucks_transactions() + return Response() + class UpdatePromMetrics(APIView): """