Closed BenBals closed 4 months ago
Can you merge main into this? Makes testing easier
* For me the poll list is not shown in the menu?
did you tick the "show in menus" checkbox? otherwise probably menu caching again
What should I review here if the calculation is not in yet?
data model, vote casting, esp. if there are some cases that I missed, like the one with restricting POSTing that you already mentioned
The menu item is now shown, might have also been a problem on my side. Data model looks ok
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
myhpi/tests/polls/test_ranked_choice_algorithm.py | 54 | 55 | 98.18% | ||
myhpi/polls/forms.py | 0 | 23 | 0.0% | ||
myhpi/polls/models.py | 123 | 150 | 82.0% | ||
<!-- | Total: | 208 | 259 | 80.31% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
myhpi/polls/models.py | 4 | 82.89% | ||
<!-- | Total: | 4 | --> |
Totals | |
---|---|
Change from base Build 7886409057: | -0.05% |
Covered Lines: | 1435 |
Relevant Lines: | 1928 |
What's left to do:
as_sensible_datastructure
performs an individual database request for each and every ballot. We expect vote numbers to be (at most) in the low thousands. Still, we should prefetch this data in calculate_votes
.
Relevant code:
def as_sensible_datastructure(self):
result = []
for entry in self.rankedchoiceballotentry_set.all():
result.append((entry.rank, entry))
heapq.heapify(result)
return result
and
def calculate_ranking(self):
ballots = list(map(lambda x: x.as_sensible_datastructure(), list(self.ballots.all())))
options = self.options.all()
[snip]
* Could add some spacing between the vote button and the footer ![image](https://private-user-images.githubusercontent.com/6863832/303944516-b25f82dd-2276-4566-a519-5b82e0ad530e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDc4MTgzMTcsIm5iZiI6MTcwNzgxODAxNywicGF0aCI6Ii82ODYzODMyLzMwMzk0NDUxNi1iMjVmODJkZC0yMjc2LTQ1NjYtYTUxOS01YjgyZTBhZDUzMGUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDAyMTNUMDk1MzM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzM1NDVlYmVhNWJmMjE4NGZhYzVmMjQ4NWZkYTlhZTEwNmQyM2IwNWNjZjQ4YmFiMWIxODdiZTEwZjk1MzIyZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.M6ys4GXmkg6BReRX01UhvnrhU2MiRu7JwYJuK-e2T2A)
@SilvanVerhoeven
closes #220 closes #81