Skip to content

Fix N+1 queries in sessão/relatórios and remove unused painel views - #3849

Open
edwardoliveira wants to merge 1 commit into
3.1.xfrom
feat/sessao-relatorio-perf
Open

Fix N+1 queries in sessão/relatórios and remove unused painel views#3849
edwardoliveira wants to merge 1 commit into
3.1.xfrom
feat/sessao-relatorio-perf

Conversation

@edwardoliveira

Copy link
Copy Markdown
Contributor

Performance-only slice extracted from feat/rate-limiter-2026 (commit 2f2a976), which bundled query-optimization work in with unrelated rate-limiter/caching changes.

  • customize_link_materia() and the Ordem do Dia / Expediente ListViews now use prefetched querysets instead of per-row queries.
  • get_etiqueta_protocolos() batch-fetches MateriaLegislativa and DocumentoAdministrativo instead of querying per protocolo in a loop.
  • New migration redefines the materia_materiaemtramitacao view and adds a concurrent index (tram_materia_id_desc) backing the tramitacao prefetch.
  • Drops a redundant .distinct() + order_by on a related field in RelatorioMateriasTramitacaoFilterSet.qs.
  • Removes the unused painel_mensagem/parlamentar/votacao views and templates (also bundled into 2f2a976 by mistake).
  • Adds CLAUDE.md project documentation.

Note: feat/painel-votacao-v2 still imports painel_mensagem_view, painel_parlamentar_view and painel_votacao_view. That branch will need reconciling with this removal when it's rebased onto 3.1.x.

Descrição

Issue Relacionada

Motivação e Contexto

Como Isso Foi Testado?

Capturas de Tela (se apropriado):

Tipos de Mudanças

  • Bug fix (alteração que corrige uma issue e não altera funcionalidades já existentes)
  • Nova feature (alteração que adiciona uma funcionalidade e não altera funcionalidades já existentes)
  • Alteração disruptiva (Breaking change) (Correção ou funcionalidade que causa alteração nas funcionalidades existentes)

Checklist:

  • Eu li o documento de Contribuição (CONTRIBUTING).
  • Meu código segue o estilo de código deste projeto.
  • Minha alteração requer uma alteração na documentação.
  • Eu atualizei a documentação de acordo.
  • Eu adicionei testes para cobrir minhas mudanças.
  • Todos os testes novos e existentes passaram.

Performance-only slice extracted from feat/rate-limiter-2026 (commit
2f2a976), which bundled query-optimization work in with unrelated
rate-limiter/caching changes.

- customize_link_materia() and the Ordem do Dia / Expediente ListViews
  now use prefetched querysets instead of per-row queries.
- get_etiqueta_protocolos() batch-fetches MateriaLegislativa and
  DocumentoAdministrativo instead of querying per protocolo in a loop.
- New migration redefines the materia_materiaemtramitacao view and adds
  a concurrent index (tram_materia_id_desc) backing the tramitacao
  prefetch.
- Drops a redundant .distinct() + order_by on a related field in
  RelatorioMateriasTramitacaoFilterSet.qs.
- Removes the unused painel_mensagem/parlamentar/votacao views and
  templates (also bundled into 2f2a976 by mistake).
- Adds CLAUDE.md project documentation.

Note: feat/painel-votacao-v2 still imports painel_mensagem_view,
painel_parlamentar_view and painel_votacao_view. That branch will need
reconciling with this removal when it's rebased onto 3.1.x.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@edwardoliveira
edwardoliveira force-pushed the feat/sessao-relatorio-perf branch from f37c574 to 9269bc1 Compare August 7, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant