fsr-de / myHPI

Django/Wagtail page serving myhpi.de
https://myhpi.de
11 stars 11 forks source link

Instant run-off elections #438

Closed BenBals closed 4 months ago

BenBals commented 6 months ago

closes #220 closes #81

frcroth commented 5 months ago

Can you merge main into this? Makes testing easier

jeriox commented 5 months ago
* 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

frcroth commented 5 months ago

The menu item is now shown, might have also been a problem on my side. Data model looks ok

coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 7887481246

Details


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 Coverage Status
Change from base Build 7886409057: -0.05%
Covered Lines: 1435
Relevant Lines: 1928

💛 - Coveralls
BenBals commented 4 months ago

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]
jeriox commented 4 months ago
* 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