Skip to content

feat(report): adiciona totais de elementos visuais por artigo - #1484

Merged
samuelveigarangel merged 15 commits into
scieloorg:mainfrom
samuelveigarangel:feat/visual-element-totals
Sep 30, 2026
Merged

samuelveigarangel merged 15 commits into
scieloorg:mainfrom
samuelveigarangel:feat/visual-element-totals

Conversation

@samuelveigarangel

@samuelveigarangel samuelveigarangel commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

O que esse PR faz?

Persiste, por artigo e idioma, a quantidade de fig, table-wrap, fórmulas e graphic extraída do XML, e expõe esses totais numa tela administrativa com filtro e download em CSV.

  • ArticleCount passa a apontar para Article, com unicidade por artigo, tipo e idioma.
  • Os códigos dos tipos visuais ficam em ArticleCountType.
  • A carga e o salvamento do XML atualizam as contagens; a task task_create_article_visual_counts preenche artigos já carregados.
  • A tela Visual elements totals fica no menu Articles, com totais por ano e planilha separada por ;.

Onde a revisão poderia começar?

  1. article/models.py (ArticleCount, ArticleCountType e Article.create_or_update_article_visual_counts)
  2. article/migrations/0051_articlecount_article.py
  3. article/sources/xmlsps.py (count_visual_and_formula_items e create_or_update_article_counts)
  4. report/visual_element_totals.py e report/views.py

Como este poderia ser testado manualmente?

  1. Aplicar a migração: python manage.py migrate article.
  2. Rodar os testes:
    • python manage.py test article.tests.test_visual_element_counts article.tests.test_task_update_article_visual_counts report.tests.VisualElementTotalsQueryTest
  3. No admin, abrir Articles → Visual elements totals.
  4. Filtrar por coleção, área temática e periódico (a busca do periódico filtra a lista já carregada).
  5. Conferir os totais por ano e baixar a planilha.
  6. Abrir o CSV com separador ; e conferir que coleções múltiplas (scl; sss) permanecem na coluna collection.

Algum cenário de contexto que queira dar?

graphic dentro de fig ou table-wrap não entra na contagem de graphic. Contagens que o XML não traz mais são removidas; as que permanecem são atualizadas com update_or_create.

Screenshots

image image

Quais são os tickets relevantes?

#1468

Referências

Nenhuma referência externa.


Segurança da informação (NSI.04)

Seção obrigatória. Marque as opções aplicáveis e justifique quando necessário. Referência: NSI.04 - Norma de Desenvolvimento Seguro.

Este PR manipula dados sensíveis ou pessoais (LGPD)?

  • Sim — descreva os controles de proteção aplicados (criptografia, mascaramento, anonimização, etc.):
  • Não

Este PR altera autenticação, autorização, controle de acesso ou gerenciamento de sessão?

  • Sim — descreva o que mudou e por quê:
  • Não

Este PR introduz, atualiza ou remove dependências de terceiros?

  • Sim — as novas dependências foram verificadas no SBOM/Trivy sem vulnerabilidades críticas/altas em aberto?
    • Verificado e aprovado
    • Pendente / vulnerabilidade aceita com justificativa:
  • Não

Este PR foi validado pelo pipeline de segurança (SonarQube / Trivy)?

  • Sim — link do job:
  • Não aplicável a este PR (justifique): a validação ocorre no CI deste PR após a abertura.

Este PR concatena, monta ou executa comandos SQL, HTML ou JavaScript a partir de entrada externa?

  • Sim — confirme que há sanitização/parametrização (prepared statements, escaping, etc.):
  • Não

Este PR expõe novos endpoints, telas ou serviços?

  • Sim — HTTPS obrigatório está garantido e o acesso segue o princípio de menor privilégio?
  • Não

As rotas ficam em /admin/report/visual-element-totals/ e /admin/report/visual-element-totals/csv/, no admin do Wagtail, atrás do login administrativo.

Algum segredo, senha, chave ou token está sendo adicionado ao código-fonte?

  • Não, nenhum segredo foi commitado
  • Sim (bloquear merge e corrigir antes de prosseguir)

Made with Cursor

samuelveigarangel and others added 5 commits September 29, 2026 23:34
Move visual type codes to ArticleCountType, attach counts to Article and drop CommonControlField from the count models.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Count fig, table-wrap, formula and graphic totals when the article XML is loaded or saved.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add tests for XML counting, count replacement and the backfill task.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@samuelveigarangel
samuelveigarangel force-pushed the feat/visual-element-totals branch from c1f0c17 to 175314a Compare September 30, 2026 02:50
samuelveigarangel and others added 2 commits September 29, 2026 23:52
Add a filterable yearly totals view, semicolon CSV export and a menu item under Articles.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@pitangainnovare pitangainnovare left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foram solicitadas duas alterações:

  • Corrigir testes em report
  • Fazer code ser unique

samuelveigarangel and others added 6 commits September 30, 2026 13:40
Add a PID v2 or v3 field so the totals view and spreadsheet can be limited to one article.

Co-authored-by: Cursor <cursoragent@cursor.com>
Prevent duplicate visual count type codes when creating counts from XML.

Co-authored-by: Cursor <cursoragent@cursor.com>
…unt migration

Keep the constraint in the branch migration instead of adding a follow-up.

Co-authored-by: Cursor <cursoragent@cursor.com>
Emit a column only for languages present in the data, keep nd last, and count both missing languages and code2 nd.

Co-authored-by: Cursor <cursoragent@cursor.com>
Assert column order, the nd suffix for missing languages, and counts stored with code2 nd.

Co-authored-by: Cursor <cursoragent@cursor.com>
Show the result phrase only when both the page count and the total are present.

Co-authored-by: Cursor <cursoragent@cursor.com>

@pitangainnovare pitangainnovare left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funciona como esperado.

Image

Sugiro um novo nome pra tela: Figure, Table and Equation Counts

samuelveigarangel and others added 2 commits September 30, 2026 15:39
Use the same label on the admin menu and on the report page.

Co-authored-by: Cursor <cursoragent@cursor.com>
Limit the journal list to the selected collection, drop the dashed empty label, and keep the select visible on a white background.

Co-authored-by: Cursor <cursoragent@cursor.com>
@samuelveigarangel
samuelveigarangel merged commit 949a319 into scieloorg:main Sep 30, 2026
3 of 5 checks passed
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.

2 participants