Browse Source

Otimização de consultas

pull/1493/head
Edward Ribeiro 7 years ago
parent
commit
cd52706b70
  1. 7
      sapl/norma/views.py
  2. 3
      sapl/sessao/views.py

7
sapl/norma/views.py

@ -64,6 +64,13 @@ class NormaPesquisaView(FilterView):
filterset_class = NormaFilterSet filterset_class = NormaFilterSet
paginate_by = 10 paginate_by = 10
def get_queryset(self):
qs = super().get_queryset()
qs.select_related('tipo', 'materia')
return qs
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(NormaPesquisaView, self).get_context_data(**kwargs) context = super(NormaPesquisaView, self).get_context_data(**kwargs)

3
sapl/sessao/views.py

@ -2429,7 +2429,8 @@ class PesquisarSessaoPlenariaView(FilterView):
kwargs = {'data': self.request.GET or None} kwargs = {'data': self.request.GET or None}
qs = self.get_queryset() qs = self.get_queryset().select_related(
'tipo', 'sessao_legislativa', 'legislatura')
qs = qs.distinct().order_by( qs = qs.distinct().order_by(
'-legislatura__numero', '-data_inicio', '-numero') '-legislatura__numero', '-data_inicio', '-numero')

Loading…
Cancel
Save