diff --git a/app/grants/clr.py b/app/grants/clr.py index 7c70aad5d18..74763a36c26 100644 --- a/app/grants/clr.py +++ b/app/grants/clr.py @@ -243,14 +243,20 @@ def calculate_clr_for_donation(donation_grant, donation_amount, total_pot, base_ print('error: could not find grant in final grants_clr data') return (None, None) -def predict_clr(random_data=False, save_to_db=False, from_date=None): +def predict_clr(random_data=False, save_to_db=False, from_date=None, clr_type=None, network='mainnet'): # setup clr_calc_start_time = timezone.now() # get all the eligible contributions and calculate total contributions = Contribution.objects.prefetch_related('subscription').filter(created_on__gte=CLR_START_DATE, created_on__lte=from_date) debug_output = [] - grants = Grant.objects.all() + + if clr_type == 'tech': + grants = Grant.objects.filter(network=network, hidden=False, grant_type='tech') + elif clr_type == 'media': + grants = Grant.objects.filter(network=network, hidden=False, grant_type='tech') + else: + grants = Grant.objects.filter(network=network, hidden=False) # set up data to load contributions for each grant if not random_data: diff --git a/app/grants/management/commands/estimate_clr.py b/app/grants/management/commands/estimate_clr.py index e23174e72f5..ddab1fe3366 100644 --- a/app/grants/management/commands/estimate_clr.py +++ b/app/grants/management/commands/estimate_clr.py @@ -32,13 +32,27 @@ class Command(BaseCommand): help = 'calculate CLR estimates for all grants' + def add_arguments(self, parser): + + parser.add_argument('clr_type', type=str, default='all', choices=['tech', 'media', 'all']) + parser.add_argument('network', type=str, default='mainnet', choices=['rinkeby', 'mainnet']) + def handle(self, *args, **options): - clr_prediction_curves = predict_clr(random_data=False, save_to_db=True, from_date=timezone.now()) + clr_type = options['clr_type'] + network = options['network'] + + clr_prediction_curves = predict_clr( + random_data=False, + save_to_db=True, + from_date=timezone.now(), + clr_type=clr_type, + network=network + ) # Uncomment these for debugging and sanity checking # for grant in clr_prediction_curves: #print("CLR predictions for grant {}".format(grant['grant'])) - #print("All grants: {}".format(grant['grants_clr'])) + #print("All grants: {}".clr_typeformat(grant['grants_clr'])) #print("prediction curve: {}\n\n".format(grant['clr_prediction_curve'])) # sanity check: sum all the estimated clr distributions - should be close to CLR_DISTRIBUTION_AMOUNT diff --git a/app/grants/models.py b/app/grants/models.py index 974a5576901..885198942b0 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -218,7 +218,7 @@ class Meta: def __str__(self): """Return the string representation of a Grant.""" - return f"id: {self.pk}, active: {self.active}, title: {self.title}" + return f"id: {self.pk}, active: {self.active}, title: {self.title}, type: {self.grant_type}" def percentage_done(self): diff --git a/scripts/crontab b/scripts/crontab index e6ea2d92a66..7d57a1cb4f1 100644 --- a/scripts/crontab +++ b/scripts/crontab @@ -43,8 +43,8 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/us 1 1 1 * * cd gitcoin/coin; bash scripts/run_management_command.bash activity_report $(date --date='-1 month' +%Y/%m/%d) $(date +%Y/%m/%d) >> /var/log/gitcoin/activity_report.log 2>&1 ## CLR -### NOT ACTIVE -#### 0 */4 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash estimate_clr >> /var/log/gitcoin/estimate_clr.log 2>&1 +#### 0 */4 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash estimate_clr tech mainnet >> /var/log/gitcoin/estimate_clr_tech.log 2>&1 +#### 0 */4 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash estimate_clr media mainnet >> /var/log/gitcoin/estimate_clr_media.log 2>&1 ## GITCOIN MARKETING 30 */12 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash sync_mail >> /var/log/gitcoin/sync_mail.log 2>&1