Skip to content

Commit

Permalink
bug: ignore grant removed from round in clr calculation (#9876)
Browse files Browse the repository at this point in the history
* bug: ignore grant removed from round in clr calculation

* Update app/grants/clr.py

Co-authored-by: Graham Dixon <[email protected]>

Co-authored-by: Graham Dixon <[email protected]>
  • Loading branch information
thelostone-mc and gdixon authored Dec 14, 2021
1 parent b4563fe commit e864f2a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/grants/clr.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import numpy as np
from grants.clr_data_src import fetch_contributions, fetch_grants, fetch_summed_contributions
from grants.models import GrantCLRCalculation


def populate_data_for_clr(grants, contributions, clr_round):
Expand Down Expand Up @@ -485,7 +486,11 @@ def predict_clr(save_to_db=False, from_date=None, clr_round=None, network='mainn
print(f"- starting grants iter at {round(time.time(),1)}")
# for full calc - calculate the clr for each grant given additional potential_donations
total_count = grants.count()

invalid_clr_calculations = GrantCLRCalculation.objects.filter(latest=True, grantclr=clr_round.pk)

for grant in grants:
invalid_clr_calculations.exclude(grant=grant.pk)
# five potential additional donations plus the base case of 0
potential_donations = [0, 1, 10, 100, 1000, 10000]

Expand Down Expand Up @@ -545,6 +550,8 @@ def predict_clr(save_to_db=False, from_date=None, clr_round=None, network='mainn

debug_output.append({'grant': grant.id, "title": grant.title, "clr_prediction_curve": (potential_donations, potential_clr), "grants_clr": grants_clr})

invalid_clr_calculations.update(latest=False, active=False)

print(f"\nTotal execution time: {(timezone.now() - clr_calc_start_time)}\n")

return debug_output

0 comments on commit e864f2a

Please sign in to comment.