Skip to content

Commit a5bc608

Browse files
authored
Calculating the total contribution amount from the GrantContributionIndex + fix in the compute_grant_contribution_index command (#10766)
1 parent 823a529 commit a5bc608

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

app/grants/management/commands/compute_grant_contribution_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def handle(self, *args, **kwargs):
3131
.order_by("id")
3232
.distinct("id")
3333
.values_list(
34-
"id",
34+
"profile_for_clr_id",
3535
"subscription__grant__clr_calculations__grantclr__round_num",
3636
"subscription__grant__id",
3737
"amount_per_period_usdt"

app/grants/views_api_vc.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,15 @@ def contributor_statistics(request):
9090
.count()
9191
)
9292

93-
# Get the total number of contributions
94-
contribution_list = list(
95-
Contribution.objects.filter(
96-
profile_for_clr__handle=handle,
97-
success=True,
98-
subscription__network="mainnet",
99-
subscription__grant__clr_calculations__latest=True,
100-
)
101-
.order_by(
102-
"id",
103-
)
104-
.distinct(
105-
"id",
106-
)
107-
.values_list("id", "amount_per_period_usdt")
108-
)
93+
# Get the total contribution amount
94+
total_contribution_amount = GrantContributionIndex.objects.filter(
95+
profile__handle=handle
96+
).aggregate(total_contribution_amount=Sum("amount"))["total_contribution_amount"]
97+
98+
total_contribution_amount
10999

110-
total_contribution_amount = sum([i[1] for i in contribution_list])
100+
if total_contribution_amount is None:
101+
total_contribution_amount = 0
111102

112103
# GR14 contributor (and not squelched by FDD)
113104
start = datetime.now()

0 commit comments

Comments
 (0)