|
| 1 | +from grants.models import * |
| 2 | +from grants.views import clr_round as round_num |
| 3 | +from django.utils import timezone |
| 4 | +from django.db.models import Count |
| 5 | + |
| 6 | + |
| 7 | +def round_num_to_dates(round_id): |
| 8 | + start = timezone.now() |
| 9 | + end = timezone.now() |
| 10 | + amount = 9 |
| 11 | + if round_id == 1: |
| 12 | + start = timezone.datetime(2019, 2, 1) |
| 13 | + end = timezone.datetime(2019, 2, 15) |
| 14 | + amount = 25000 |
| 15 | + if round_id == 2: |
| 16 | + start = timezone.datetime(2019, 3, 26) |
| 17 | + end = timezone.datetime(2019, 4, 19) |
| 18 | + amount = 50000 |
| 19 | + if round_id == 3: |
| 20 | + start = timezone.datetime(2019, 9, 15) |
| 21 | + end = timezone.datetime(2019, 10, 4) |
| 22 | + amount = 100000 |
| 23 | + if round_id == 4: |
| 24 | + start = timezone.datetime(2020, 1, 6) |
| 25 | + end = timezone.datetime(2020, 1, 21) |
| 26 | + amount = 200000 |
| 27 | + if round_id == 5: |
| 28 | + start = timezone.datetime(2020, 3, 23) |
| 29 | + end = timezone.datetime(2020, 4, 5) |
| 30 | + amount = 250000 |
| 31 | + if round_id == 6: |
| 32 | + start = timezone.datetime(2020, 6, 16) |
| 33 | + end = timezone.datetime(2020, 7, 3) |
| 34 | + amount = 175000 |
| 35 | + if round_id == 7: |
| 36 | + start = timezone.datetime(2020, 9, 15) |
| 37 | + end = timezone.datetime(2020, 10, 3) |
| 38 | + amount = 120 * 3 * 1000 |
| 39 | + return start, end, amount |
| 40 | + |
| 41 | +for i in range(1, 6): |
| 42 | + skip = GrantCLR.objects.filter(round_num=i).exists() |
| 43 | + if not skip: |
| 44 | + start, end, amount = round_num_to_dates(i) |
| 45 | + GrantCLR.objects.create( |
| 46 | + round_num=i, |
| 47 | + start_date=start, |
| 48 | + end_date=end, |
| 49 | + total_pot=amount, |
| 50 | + ) |
| 51 | + |
| 52 | +from_handles = ['owocki', 'vs77bb', 'ceresstation', 'gitcoinbot', 'gitcoingranterog'] |
| 53 | +for i in range(3, 5): |
| 54 | + start, end, amount = round_num_to_dates(i) |
| 55 | + payout_range = (end, end + timezone.timedelta(weeks=4)) |
| 56 | + _contribs = Contribution.objects.filter(created_on__gt=payout_range[0], created_on__lt=payout_range[1]) |
| 57 | + contribs = Contribution.objects.filter(subscription__contributor_profile__handle__in=from_handles, created_on__gt=payout_range[0], created_on__lt=payout_range[1]) |
| 58 | + for contrib in contribs: |
| 59 | + CLRMatch.objects.create( |
| 60 | + round_number=i, |
| 61 | + amount=contrib.subscription.amount_per_period_usdt, |
| 62 | + grant=contrib.subscription.grant, |
| 63 | + ready_for_payout=True, |
| 64 | + payout_tx=contrib.tx_id, |
| 65 | + payout_tx_date=contrib.created_on, |
| 66 | + payout_contribution=contrib, |
| 67 | + comments='retroactive payout created by backfill_match_info.py' |
| 68 | + ) |
| 69 | + #__sum = sum(_contribs.values_list('subscription__amount_per_period_usdt', flat=True)) |
| 70 | + #_sum = sum(contribs.values_list('subscription__amount_per_period_usdt', flat=True)) |
| 71 | + #print(_contribs.values_list('subscription__contributor_profile__handle').annotate(Count("id")).order_by('-id__count')) |
| 72 | + #print(i, _contribs.count(), contribs.count(), __sum, _sum) |
| 73 | + |
| 74 | + |
0 commit comments