Skip to content

Commit

Permalink
calculate score based on implementation groups
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-intuitem committed May 8, 2024
1 parent 2490773 commit 6a848dc
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,10 +1290,17 @@ def get_global_score(self):
.exclude(status=RequirementAssessment.Status.NOT_APPLICABLE)
.exclude(is_scored=False)
)
score = requirement_assessments_scored.aggregate(models.Avg("score"))
if score["score__avg"] is not None:
return round(score["score__avg"], 1)
return -1
ig = set(self.selected_implementation_groups)
score = 0
n = 0
for ras in requirement_assessments_scored:
if not(ig) or (ig & set(ras.requirement.implementation_groups)):
score += ras.score
n += 1
if n > 0:
return round(score/n, 1)
else:
return -1

def get_selected_implementation_groups(self):
framework = self.framework
Expand Down

0 comments on commit 6a848dc

Please sign in to comment.