Utilise select_related
This commit is contained in:
parent
3ecea69d2c
commit
875b80b2a6
1 changed files with 4 additions and 2 deletions
|
@ -278,7 +278,7 @@ class BallotsData:
|
||||||
"""Renvoie un tableau affichant les options sélectionnées pour chaque bulletin"""
|
"""Renvoie un tableau affichant les options sélectionnées pour chaque bulletin"""
|
||||||
from .models import Vote
|
from .models import Vote
|
||||||
|
|
||||||
votes = Vote.objects.filter(option__question=question)
|
votes = Vote.objects.filter(option__question=question).select_related("user")
|
||||||
|
|
||||||
options = list(question.options.all())
|
options = list(question.options.all())
|
||||||
|
|
||||||
|
@ -298,7 +298,9 @@ class BallotsData:
|
||||||
from .models import Rank
|
from .models import Rank
|
||||||
|
|
||||||
options = list(question.options.all())
|
options = list(question.options.all())
|
||||||
ranks = Rank.objects.select_related("vote").filter(vote__option__in=options)
|
ranks = Rank.objects.select_related("vote__user").filter(
|
||||||
|
vote__option__in=options
|
||||||
|
)
|
||||||
ranks_by_user = {}
|
ranks_by_user = {}
|
||||||
|
|
||||||
for r in ranks:
|
for r in ranks:
|
||||||
|
|
Loading…
Reference in a new issue