Skip to content

Commit

Permalink
Create a true Python list of these objects
Browse files Browse the repository at this point in the history
Create a true Python list to ensure that you only query the database once to generate the public key of the election, without the need for further queries.

I would like to register the other members who helped to identify this issue:
 - Thiago Alexandre Herek - UTFPR / Brazil
 - José Gonçalves De Oliveira Júnior - UTFPR / Brazil
 - Joilson Alves Júnior - UTFPR / Brazil
 - Paulo Matias - UFSCar / Brazil (@thotypous)
  • Loading branch information
eduardormanika authored and benadida committed Aug 17, 2020
1 parent 755b038 commit b54ffd0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions helios/models.py
Expand Up @@ -510,7 +510,7 @@ def freeze(self):
self.set_eligibility()

# public key for trustees
trustees = Trustee.get_by_election(self)
trustees = list(Trustee.get_by_election(self))
combined_pk = trustees[0].public_key
for t in trustees[1:]:
combined_pk = combined_pk * t.public_key
Expand Down Expand Up @@ -1171,7 +1171,7 @@ def save(self, *args, **kwargs):

@classmethod
def get_by_election(cls, election):
return cls.objects.filter(election = election).order_by('id')
return cls.objects.filter(election = election)

@classmethod
def get_by_uuid(cls, uuid):
Expand Down

0 comments on commit b54ffd0

Please sign in to comment.