Skip to content
Snippets Groups Projects
Commit b54ffd0f authored by eduardormanika's avatar eduardormanika Committed by Ben Adida
Browse files

Create a true Python list of these objects

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)
parent 755b0380
No related branches found
No related tags found
No related merge requests found
...@@ -510,7 +510,7 @@ class Election(HeliosModel): ...@@ -510,7 +510,7 @@ class Election(HeliosModel):
self.set_eligibility() self.set_eligibility()
# public key for trustees # public key for trustees
trustees = Trustee.get_by_election(self) trustees = list(Trustee.get_by_election(self))
combined_pk = trustees[0].public_key combined_pk = trustees[0].public_key
for t in trustees[1:]: for t in trustees[1:]:
combined_pk = combined_pk * t.public_key combined_pk = combined_pk * t.public_key
...@@ -1171,7 +1171,7 @@ class Trustee(HeliosModel): ...@@ -1171,7 +1171,7 @@ class Trustee(HeliosModel):
@classmethod @classmethod
def get_by_election(cls, election): def get_by_election(cls, election):
return cls.objects.filter(election = election).order_by('id') return cls.objects.filter(election = election)
@classmethod @classmethod
def get_by_uuid(cls, uuid): def get_by_uuid(cls, uuid):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment