Skip to content

Commit

Permalink
restore var needed for mgmt command
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Jul 27, 2020
1 parent 7aa07f8 commit cd0ebba
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 23 deletions.
8 changes: 5 additions & 3 deletions app/grants/management/commands/grant_vitalik_shuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

from django.core.management.base import BaseCommand

from grants.models import Grant
from grants.views import clr_active
from grants.models import Grant, GrantCLR

# VB 2019/09/27
# > To prevent a winner-takes-all effect from grants with already the most funding being shown at the top, how about a randomized sort, where your probability of being first is equal to (your expected CLR match) / (total expected CLR match) and then you just do that recursively to position everyone?
Expand Down Expand Up @@ -56,9 +55,12 @@ class Command(BaseCommand):

def handle(self, *args, **options):

if not clr_active:
active_clr_rounds = GrantCLR.objects.filter(is_active=True)
if active_clr_rounds.count() == 0:
return

# TODO-SELF-SERVICE: Check if it's alright to shuffle all grants even if 1 CLR round is active

# set default, for when no CLR match enabled
for grant in Grant.objects.all():
grant.weighted_shuffle = 99999
Expand Down
4 changes: 2 additions & 2 deletions app/grants/management/commands/payout_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from dashboard.utils import get_tx_status, get_web3, has_tx_mined
from gas.utils import recommend_min_gas_price_to_confirm_in_time
from grants.models import CLRMatch, Contribution, Grant, Subscription
from grants.views import clr_active, clr_round, next_round_start, round_end
from grants.views import clr_round # TODO-SELF-SERVICE: REMOVE THIS
from marketing.mails import (
grant_match_distribution_final_txn, grant_match_distribution_kyc, grant_match_distribution_test_txn,
)
Expand All @@ -44,7 +44,7 @@ class Command(BaseCommand):
help = 'finalizes + sends grants round payouts'

def add_arguments(self, parser):
parser.add_argument('what',
parser.add_argument('what',
default='finalize',
type=str,
help="what do we do? (finalize, payout_test, payout_dai, prepare_final_payout)"
Expand Down
2 changes: 1 addition & 1 deletion app/grants/management/commands/sent_cart_reminder.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from dashboard.utils import get_tx_status, has_tx_mined
from grants.clr import predict_clr
from grants.models import CartActivity, Contribution, Grant, Subscription
from grants.views import clr_active, next_round_start, round_end
from grants.views import next_round_start, round_end # TODO-SELF-SERVICE: REMOVE THIS
from marketing.mails import remember_your_cart, warn_subscription_failed
from townsquare.models import MatchRound

Expand Down
9 changes: 6 additions & 3 deletions app/grants/management/commands/subminer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
from django.utils import timezone

from dashboard.utils import get_tx_status, has_tx_mined
from grants.models import Grant
from grants.views import clr_active
from grants.models import Grant, GrantCLR
from marketing.mails import warn_subscription_failed

logging.getLogger("urllib3").setLevel(logging.WARNING)
Expand Down Expand Up @@ -151,14 +150,18 @@ def handle(self, *args, **options):
grants = Grant.objects.filter(network=network).active()
logger.info("got %d grants", grants.count())

active_clr_rounds = GrantCLR.objects.filter(is_active=True)

for grant in grants:
subs = grant.subscriptions.filter(
active=True,
error=False,
next_contribution_date__lt=timezone.now(),
num_tx_processed__lt=F('num_tx_approved')
)
if not clr_active:

is_clr_active = active_clr_rounds.filter(grant_type=grant.grant_type)
if not is_clr_active:
subs = subs.exclude(frequency_unit='roundup') #dont process grant subscriptions until next round

logger.info(" - %d has %d subs ready for execution", grant.pk, subs.count())
Expand Down
4 changes: 3 additions & 1 deletion app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,22 @@
logger = logging.getLogger(__name__)
w3 = Web3(HTTPProvider(settings.WEB3_HTTP_PROVIDER))

# clr_active = False
# Round Schedule
# from canonical source of truth https://gitcoin.co/blog/gitcoin-grants-round-4/
# Round 5 - March 23th — April 7th 2020
# Round 6 - June 15th — June 29th 2020
# Round 7 - September 14th — September 28th 2020

# TODO-SELF-SERVICE: REMOVE BELOW VARIABLES NEEDED FOR MGMT
clr_round=6
last_round_start = timezone.datetime(2020, 3, 23, 12, 0)
last_round_end = timezone.datetime(2020, 4, 7, 12, 0)
# TODO, also update grants.clr:CLR_START_DATE, PREV_CLR_START_DATE, PREV_CLR_END_DATE
next_round_start = timezone.datetime(2020, 6, 15, 12, 0)
after_that_next_round_begin = timezone.datetime(2020, 9, 14, 12, 0)
round_end = timezone.datetime(2020, 7, 3, 16, 0) #tz=utc, not mst
round_types = ['media', 'tech', 'change']
# TODO-SELF-SERVICE: END

kudos_reward_pks = [12580, 12584, 12572, 125868, 12552, 12556, 12557, 125677, 12550, 12392, 12307, 12343, 12156, 12164]

Expand Down
42 changes: 29 additions & 13 deletions app/marketing/management/commands/post_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from economy.utils import convert_token_to_usdt
from grants.models import *
from grants.models import CartActivity, Contribution, PhantomFunding
from grants.views import clr_round, next_round_start, round_end
from grants.views import clr_round, next_round_start, round_end # TODO-SELF-SERVICE: REMOVE THIS
from townsquare.models import Comment

text = ''
Expand Down Expand Up @@ -344,16 +344,32 @@ def grants():
pprint("=======================")
pprint("")

active_rounds = ['tech', 'media', 'change']
from grants.clr import TOTAL_POT_TECH, TOTAL_POT_MEDIA, TOTAL_POT_CHANGE
active_round_threshold = {
'tech': TOTAL_POT_TECH,
'media': TOTAL_POT_MEDIA,
'change': TOTAL_POT_CHANGE,
}
# active_rounds = ['tech', 'media', 'change']
# from grants.clr import TOTAL_POT_TECH, TOTAL_POT_MEDIA, TOTAL_POT_CHANGE
# active_round_threshold = {
# 'tech': TOTAL_POT_TECH,
# 'media': TOTAL_POT_MEDIA,
# 'change': TOTAL_POT_CHANGE,
# }
# active_round_threshold = {
# 'tech': 0,
# 'media': 0,
# 'change': 0,
# }

active_rounds = []
active_round_threshold = {}
active_clr_rounds = GrantCLR.objects.filter(is_active=True)

for active_clr_round in active_clr_rounds:
grant_type_name = active_clr_round.grant_type.name

active_round_threshold[grant_type_name] = active_clr_round.total_pot
active_rounds.append(grant_type_name)

active_rounds_allocation = {key: 0 for key in active_rounds}
for ar in active_rounds:
grants = Grant.objects.filter(active=True, grant_type=ar, is_clr_eligible=True, hidden=False)
grants = Grant.objects.filter(active=True, grant_type__name=ar, is_clr_eligible=True, hidden=False)
for grant in grants:
try:
active_rounds_allocation[ar] += grant.clr_prediction_curve[0][1]
Expand All @@ -374,7 +390,7 @@ def grants():


############################################################################3
# new feature stats for round {clr_round}
# new feature stats for round {clr_round}
############################################################################3

subs_stats = False
Expand All @@ -397,10 +413,10 @@ def grants():
contributions = Contribution.objects.filter(created_on__gt=start, created_on__lt=end, success=True, subscription__network='mainnet')[0:100]
pprint("tx_id1, tx_id2, from address, amount, amount_minus_gitcoin, token_address")
for contribution in contributions:
pprint(contribution.tx_id,
print(contribution.tx_id,
contribution.split_tx_id,
contribution.subscription.contributor_address,
contribution.subscription.amount_per_period,
contribution.subscription.amount_per_period,
contribution.subscription.amount_per_period_minus_gas_price,
contribution.subscription.token_address)

Expand All @@ -418,7 +434,7 @@ class Command(BaseCommand):
help = 'puts grants stats on town suqare'

def add_arguments(self, parser):
parser.add_argument('what',
parser.add_argument('what',
default='',
type=str,
help="what to post"
Expand Down

0 comments on commit cd0ebba

Please sign in to comment.