Skip to content

Commit 2388f83

Browse files
authored
Adding amount to the contribution index table (#10764)
1 parent 3fbe03d commit 2388f83

File tree

5 files changed

+47
-17
lines changed

5 files changed

+47
-17
lines changed

app/dashboard/management/commands/add_main_rnd_tag.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from grants.models import Grant, GrantTag
44

5+
56
class Command(BaseCommand):
67

78
help = 'updates all approved grants to include the main-round tag'

app/dashboard/management/commands/migrate_stamp_data.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from django.utils import timezone
2222

2323
from dashboard.models import Passport, PassportStamp
24-
2524
from dashboard.passport_reader import TRUSTED_IAM_ISSUER
2625

2726

app/grants/management/commands/compute_grant_contribution_index.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,13 @@ def handle(self, *args, **kwargs):
2828
"subscription__grant__clr_calculations__grantclr__end_date"
2929
),
3030
)
31-
.order_by(
32-
"subscription__contributor_profile__id",
33-
"subscription__grant__clr_calculations__grantclr__round_num",
34-
"subscription__grant__id",
35-
)
36-
.distinct(
37-
"subscription__contributor_profile__id",
38-
"subscription__grant__clr_calculations__grantclr__round_num",
39-
"subscription__grant__id",
40-
)
31+
.order_by("id")
32+
.distinct("id")
4133
.values_list(
42-
"subscription__contributor_profile__id",
34+
"id",
4335
"subscription__grant__clr_calculations__grantclr__round_num",
4436
"subscription__grant__id",
37+
"amount_per_period_usdt"
4538
)
4639
)
4740

@@ -51,6 +44,7 @@ def handle(self, *args, **kwargs):
5144
profile_id=contribInfo[0],
5245
round_num=contribInfo[1],
5346
grant_id=contribInfo[2],
47+
amount=contribInfo[3]
5448
)
5549
for contribInfo in contributions
5650
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.24 on 2022-08-19 10:11
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('grants', '0147_grantcontributionindex'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='grantcontributionindex',
15+
name='amount',
16+
field=models.DecimalField(db_index=True, decimal_places=18, default=0, help_text='The amount contributed', max_digits=64),
17+
),
18+
]

app/grants/models/grant_contribution_index.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,27 @@
66

77
class GrantContributionIndex(SuperModel):
88
"""Stores the grants and round number to shich a user contributed to.
9-
The purpose of this table is to allow a a fast query. This will be used from
10-
the `contributor_statistics` API """
9+
The purpose of this table is to allow a a fast query. This will be used from
10+
the `contributor_statistics` API"""
1111

12-
profile = models.ForeignKey('dashboard.Profile', help_text=_('Contributor'), on_delete=models.CASCADE, db_index=True)
13-
grant = models.ForeignKey('grants.Grant', help_text=_('The grant a user contributed to'), on_delete=models.CASCADE)
14-
round_num = models.IntegerField(help_text=_('The round number a user contributed to'))
12+
profile = models.ForeignKey(
13+
"dashboard.Profile",
14+
help_text=_("Contributor"),
15+
on_delete=models.CASCADE,
16+
db_index=True,
17+
)
18+
grant = models.ForeignKey(
19+
"grants.Grant",
20+
help_text=_("The grant a user contributed to"),
21+
on_delete=models.CASCADE,
22+
)
23+
round_num = models.IntegerField(
24+
help_text=_("The round number a user contributed to")
25+
)
26+
amount = models.DecimalField(
27+
default=0,
28+
decimal_places=18,
29+
max_digits=64,
30+
db_index=True,
31+
help_text=_("The amount contributed"),
32+
)

0 commit comments

Comments
 (0)