Browse Source

HOT-FIX: melhora o desempenho de pesquisas na tela de relatórios

pull/1917/head
Edward Ribeiro 7 years ago
parent
commit
c5e9d8ab5e
  1. 9
      sapl/base/forms.py

9
sapl/base/forms.py

@ -525,6 +525,11 @@ class RelatorioAtasFilterSet(django_filters.FilterSet):
model = SessaoPlenaria model = SessaoPlenaria
fields = ['data_inicio'] fields = ['data_inicio']
@property
def qs(self):
parent = super(RelatorioAtasFilterSet, self).qs
return parent.distinct().prefetch_related('tipo').order_by('-ano', 'tipo', 'numero')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(RelatorioAtasFilterSet, self).__init__( super(RelatorioAtasFilterSet, self).__init__(
*args, **kwargs) *args, **kwargs)
@ -588,7 +593,7 @@ class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet):
@property @property
def qs(self): def qs(self):
parent = super(RelatorioHistoricoTramitacaoFilterSet, self).qs parent = super(RelatorioHistoricoTramitacaoFilterSet, self).qs
return parent.distinct().order_by('-ano', 'tipo', 'numero') return parent.distinct().prefetch_related('tipo').order_by('-ano', 'tipo', 'numero')
class Meta: class Meta:
model = MateriaLegislativa model = MateriaLegislativa
@ -628,7 +633,7 @@ class RelatorioDataFimPrazoTramitacaoFilterSet(django_filters.FilterSet):
@property @property
def qs(self): def qs(self):
parent = super(RelatorioDataFimPrazoTramitacaoFilterSet, self).qs parent = super(RelatorioDataFimPrazoTramitacaoFilterSet, self).qs
return parent.distinct().order_by('-ano', 'tipo', 'numero') return parent.distinct().prefetch_related('tipo').order_by('-ano', 'tipo', 'numero')
class Meta: class Meta:
model = MateriaLegislativa model = MateriaLegislativa

Loading…
Cancel
Save