Skip to content

Commit

Permalink
Refactor counting participants
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkohei13 committed Aug 23, 2024
1 parent 9ff68d3 commit f328c04
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def make_participations_stats_html(participations):
target_taxa_count_reached = 0
taxa_count_total = 0

number_of_participants = common_helpers.get_participant_count(participations, target_count)
number_of_participants = common_helpers.get_participant_count(participations, 1)

for participation in participations:
if participation.get("taxa_count", 0) >= target_count:
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def make_participant_html(participations):

table += "</table>"

number_of_participants = common_helpers.get_participant_count(participations, target_count)
number_of_participants = common_helpers.get_participant_count(participations, 1)

# Avoid division by zero
if number_of_participants > 0:
Expand Down
5 changes: 2 additions & 3 deletions app/helpers/common_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ def make_taxa_html(participations, challenge_data, taxa_json = ""):
# Function to calculate how many participants have reached at least a given proportion or number of taxa
def get_participant_count(participations, target_count):

# Proprtion
'''
# Proportion, UNTESTED
proportion = 0.1
count = 0
for participation in participations:
Expand All @@ -360,10 +360,9 @@ def get_participant_count(participations, target_count):
'''

# Number
limit = 1
count = 0
for participation in participations:
if participation["taxa_count"] >= limit:
if participation["taxa_count"] >= target_count:
count += 1

return count
Expand Down

0 comments on commit f328c04

Please sign in to comment.