Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jabelone committed Jul 13, 2024
1 parent 6fb8565 commit ddc86c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
12 changes: 8 additions & 4 deletions memberportal/api_member_bucks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion memberportal/api_metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
):
Expand Down
2 changes: 2 additions & 0 deletions memberportal/api_metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def put(self, request):
api_metrics.calculate_memberbucks_balance()
api_metrics.calculate_memberbucks_transactions()

return Response()


class UpdatePromMetrics(APIView):
"""
Expand Down

0 comments on commit ddc86c3

Please sign in to comment.