diff --git a/backend/src/utils/counting_results.py b/backend/src/utils/counting_results.py index d05dce7c..bf06d63c 100644 --- a/backend/src/utils/counting_results.py +++ b/backend/src/utils/counting_results.py @@ -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) diff --git a/backend/src/utils/tests/test_counting_results.py b/backend/src/utils/tests/test_counting_results.py index 7d855b67..7e5bf11b 100644 --- a/backend/src/utils/tests/test_counting_results.py +++ b/backend/src/utils/tests/test_counting_results.py @@ -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)