From 8565fdddac0aa9c4446769cc729e4b1163673698 Mon Sep 17 00:00:00 2001 From: Manank Patni Date: Thu, 2 Jul 2020 19:58:37 +0530 Subject: [PATCH] Fix CLR Normalization Calculation --- backend/downtownapi/main/clr.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/downtownapi/main/clr.py b/backend/downtownapi/main/clr.py index 3a22509..31d9992 100644 --- a/backend/downtownapi/main/clr.py +++ b/backend/downtownapi/main/clr.py @@ -100,11 +100,13 @@ def calculate_clr(aggregated_contributions, _cap=8000, total_pot=25000.0): # 1. normalize if bigtot >= total_pot: - t['clr_amount'] = ((clr_amount / bigtot) * total_pot) + clr_amount = ((clr_amount / bigtot) * total_pot) # 2. cap clr amount if clr_amount >= _cap: - t['clr_amount'] = _cap + clr_amount = _cap + + t['clr_amount'] = clr_amount # 3. calculate the total clr to be distributed bigtot_normalized_cap += t['clr_amount'] @@ -150,11 +152,13 @@ def calculate_live_clr(aggregated_contributions, business_id, _cap=8000, total_p # 1. normalize if bigtot >= total_pot: - t['clr_amount'] = ((clr_amount / bigtot) * total_pot) + clr_amount = ((clr_amount / bigtot) * total_pot) - # 2. cap clr amount + # 2. cap clr amount if clr_amount >= _cap: - t['clr_amount'] = _cap + clr_amount = _cap + + t['clr_amount'] = clr_amount # 3. calculate the total clr to be distributed bigtot_normalized_cap += t['clr_amount']