Avoid mapReduce for issue TOC sections#478
Merged
Merged
Conversation
robertatakenaka
approved these changes
Jun 23, 2026
robertatakenaka
left a comment
Member
There was a problem hiding this comment.
O método .distinct("section") vai direto ao ponto: ele pede ao banco de dados (provavelmente MongoDB, considerando a sintaxe) apenas os valores únicos, o que é infinitamente mais rápido e consome menos memória.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
O que esse PR faz?
Substitui o uso de
item_frequencies("section")na página de sumário do fascículo pordistinct("section").Essa alteração evita que o MongoEngine acione
mapReducepara listar as seções dos artigos, reduzindo logs e operações temporárias no MongoDB como criação de coleçõestmp.mr.article_*,dropdeinlineerenameCollection.Onde a revisão poderia começar?
opac/webapp/main/views.pyA revisão pode começar pela função
issue_toc, no trecho que monta a lista de seções do fascículo.Como este poderia ser testado manualmente?
tmp.mr.article_*oumapReduce.Algum cenário de contexto que queira dar?
Os logs do MongoDB estavam mostrando operações repetidas de
mapReduce, com criação de coleções temporáriastmp.mr.article_*, remoção da coleçãoinlinee renomeação da coleção temporária.A chamada
item_frequenciesera usada apenas para obter os nomes distintos das seções. Como a contagem/frequência não era utilizada,distinct("section")atende ao mesmo objetivo de forma mais simples e sem acionarmapReduce.Screenshots
Não aplicável. A alteração é interna e não muda a interface visual esperada.
Quais são tickets relevantes?
Não informado.
Referências
tmp.mr.article_*,drop opac_br.inlineerenameCollection.opac/webapp/main/views.py.