forked from DGNum/gestioCOF
Petit refactor
This commit is contained in:
parent
8d11044610
commit
b450cb09e6
1 changed files with 8 additions and 5 deletions
|
@ -1407,16 +1407,13 @@ def history_json(request):
|
|||
transfers_only = request.POST.get("transfersonly", None)
|
||||
opes_only = request.POST.get("opesonly", None)
|
||||
|
||||
# Construction de la requête (sur les opérations) pour le prefetch
|
||||
ope_queryset_prefetch = Operation.objects.select_related(
|
||||
"article", "canceled_by", "addcost_for"
|
||||
)
|
||||
ope_prefetch = Prefetch("opes", queryset=ope_queryset_prefetch)
|
||||
# Construction de la requête (sur les transferts) pour le prefetch
|
||||
|
||||
transfer_queryset_prefetch = Transfer.objects.select_related(
|
||||
"from_acc", "to_acc", "canceled_by"
|
||||
)
|
||||
|
||||
# Le check sur les comptes est dans le prefetch pour les transferts
|
||||
if accounts:
|
||||
transfer_queryset_prefetch = transfer_queryset_prefetch.filter(
|
||||
Q(from_acc__trigramme__in=accounts) | Q(to_acc__trigramme__in=accounts)
|
||||
|
@ -1435,6 +1432,12 @@ def history_json(request):
|
|||
"transfers", queryset=transfer_queryset_prefetch, to_attr="filtered_transfers"
|
||||
)
|
||||
|
||||
# Construction de la requête (sur les opérations) pour le prefetch
|
||||
ope_queryset_prefetch = Operation.objects.select_related(
|
||||
"article", "canceled_by", "addcost_for"
|
||||
)
|
||||
ope_prefetch = Prefetch("opes", queryset=ope_queryset_prefetch)
|
||||
|
||||
# Construction de la requête principale
|
||||
opegroups = (
|
||||
OperationGroup.objects.prefetch_related(ope_prefetch)
|
||||
|
|
Loading…
Reference in a new issue