Skip to content

Commit

Permalink
Merge pull request #5739 from gitcoinco/save-empty-curve-clr
Browse files Browse the repository at this point in the history
save empty curve if no contributions to fix sorting
  • Loading branch information
thelostone-mc authored Jan 8, 2020
2 parents cd7fe0f + 8152bbe commit 4c1b8f1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions app/grants/clr.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,17 @@ def predict_clr(random_data=False, save_to_db=False, from_date=None, clr_type=No
base = grant.clr_prediction_curve[0][1]
if base:
grant.clr_prediction_curve = [[ele[0], ele[1], ele[1] - base] for ele in grant.clr_prediction_curve ]
JSONStore.objects.create(
created_on=from_date,
view='clr_contribution',
key=f'{grant.id}',
data=grant.clr_prediction_curve,
)
if from_date > (clr_calc_start_time - timezone.timedelta(hours=1)):
grant.save()
else:
grant.clr_prediction_curve = [[0.0, 0.0, 0.0] for x in range(0, 6)]

JSONStore.objects.create(
created_on=from_date,
view='clr_contribution',
key=f'{grant.id}',
data=grant.clr_prediction_curve,
)
if from_date > (clr_calc_start_time - timezone.timedelta(hours=1)):
grant.save()

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

0 comments on commit 4c1b8f1

Please sign in to comment.