From b54ffd0f5bbea3a62c16e4d564937e7c8109b7d0 Mon Sep 17 00:00:00 2001 From: eduardormanika <67868473+eduardormanika@users.noreply.github.com> Date: Thu, 9 Jul 2020 00:25:09 -0300 Subject: [PATCH] Create a true Python list of these objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- helios/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helios/models.py b/helios/models.py index 1c17f15..96e83dd 100644 --- a/helios/models.py +++ b/helios/models.py @@ -510,7 +510,7 @@ class Election(HeliosModel): 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 @@ -1171,7 +1171,7 @@ class Trustee(HeliosModel): @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): -- GitLab