|
24 | 24 |
|
25 | 25 | import numpy as np |
26 | 26 | from grants.clr_data_src import fetch_contributions, fetch_grants, fetch_summed_contributions |
| 27 | +from grants.models import GrantCLRCalculation |
27 | 28 |
|
28 | 29 |
|
29 | 30 | def populate_data_for_clr(grants, contributions, clr_round): |
@@ -485,7 +486,11 @@ def predict_clr(save_to_db=False, from_date=None, clr_round=None, network='mainn |
485 | 486 | print(f"- starting grants iter at {round(time.time(),1)}") |
486 | 487 | # for full calc - calculate the clr for each grant given additional potential_donations |
487 | 488 | total_count = grants.count() |
| 489 | + |
| 490 | + invalid_clr_calculations = GrantCLRCalculation.objects.filter(latest=True, grantclr=clr_round.pk) |
| 491 | + |
488 | 492 | for grant in grants: |
| 493 | + invalid_clr_calculations.exclude(grant=grant.pk) |
489 | 494 | # five potential additional donations plus the base case of 0 |
490 | 495 | potential_donations = [0, 1, 10, 100, 1000, 10000] |
491 | 496 |
|
@@ -545,6 +550,8 @@ def predict_clr(save_to_db=False, from_date=None, clr_round=None, network='mainn |
545 | 550 |
|
546 | 551 | debug_output.append({'grant': grant.id, "title": grant.title, "clr_prediction_curve": (potential_donations, potential_clr), "grants_clr": grants_clr}) |
547 | 552 |
|
| 553 | + invalid_clr_calculations.update(latest=False, active=False) |
| 554 | + |
548 | 555 | print(f"\nTotal execution time: {(timezone.now() - clr_calc_start_time)}\n") |
549 | 556 |
|
550 | 557 | return debug_output |
0 commit comments