Skip to content

Commit

Permalink
fix: bug with group maximum counting
Browse files Browse the repository at this point in the history
- the value defaults to 0
- this meant everything was viewed as over
  • Loading branch information
brownben committed Apr 1, 2024
1 parent 67f2f42 commit f9849d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
4 changes: 3 additions & 1 deletion backend/src/utils/counting_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ def find_counting_results(
# Add the top results up to the minimum counting
counting_results.update(sorted_results_in_group[:group_min])
remaining_results.difference_update(counting_results)

# Remove the bottom results which included would take the number over the maximum
remaining_results.difference_update(sorted_results_in_group[group_max:])
if group_max and group_max > 0:
remaining_results.difference_update(sorted_results_in_group[group_max:])

# Then add the largest results left until the max number is reached
number_of_results_left = max_number_of_counting_results - len(counting_results)
Expand Down
14 changes: 0 additions & 14 deletions backend/src/utils/tests/test_counting_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,20 +261,6 @@ def test_league_groups_too_many_for_group(self) -> None:
),
set([results[0], results[2], results[1]]),
)
self.assertEqual(
find_counting_results(
results,
events=[
event("0", group=SHORT_GROUP),
event("2", group=SHORT_GROUP),
event("4", group=SHORT_GROUP),
event("3", group=SHORT_GROUP),
],
league=league_config(number_of_counting_events=3),
league_groups={SHORT_GROUP: (0, 0)},
),
set([results[1]]),
)

def test_league_groups_too_few_for_group(self) -> None:
results = generate_results(50, 45, 59, 41, 48)
Expand Down

0 comments on commit f9849d3

Please sign in to comment.