Skip to content

Commit

Permalink
Merge pull request #86 from aleksandrkaekhtin/feature/rewards
Browse files Browse the repository at this point in the history
Fix rewards distribution
  • Loading branch information
aleksandrkaekhtin authored Jul 12, 2024
2 parents 2b37d02 + 7cca134 commit 8e8ed9d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions models/scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def normalized_min_max(self, p: ProjectStat, field: str, metrics):
"""
def calculate_rewards(self, projects: List[ProjectStat]) -> List[ProjectStat]:
remains = 0
assigned_full_rewards = 0
if not self.reward_list:
return projects
reward_iterator = iter(self.reward_list)
Expand All @@ -92,13 +93,14 @@ def calculate_rewards(self, projects: List[ProjectStat]) -> List[ProjectStat]:
remains += reward - project.metrics[ProjectStat.POSSIBLE_REWARD]
else:
project.metrics[ProjectStat.REWARD] = reward
if not project.metrics[ProjectStat.POSSIBLE_REWARD]:
assigned_full_rewards += reward
else:
project.metrics[ProjectStat.REWARD] = 0
if remains:
assigned_rewards = sum(self.reward_list) - remains
for project in projects:
if project.metrics[ProjectStat.REWARD] and not project.metrics[ProjectStat.POSSIBLE_REWARD]:
project.metrics[ProjectStat.REWARD] += remains * project.metrics[ProjectStat.REWARD] / assigned_rewards
project.metrics[ProjectStat.REWARD] += remains * project.metrics[ProjectStat.REWARD] / assigned_full_rewards
return projects

def calculate(self, metrics: List[ProjectStat]):
Expand Down

0 comments on commit 8e8ed9d

Please sign in to comment.