feature: entityArticles — artigos de entidade via Postgres (fix página /entidades)#22
Merged
Merged
Conversation
…ense) Adiciona resolver entityArticles(entityId, page, limit) que consulta news_entities → news diretamente no Postgres, sem depender do campo entityCanonical no Typesense (reprocessamento ainda pendente). - _ENTITY_ARTICLES_SQL: CTE deduplica por unique_id, conta total sem window fn no outer SELECT, ordena por published_at DESC - PostgresDatasource.get_entity_articles(): retorna (records, total_count) - EntityQuery.entity_articles(): mapeaia NewsRecord → Article via helper _news_record_to_article; safe clamp em page/limit - SDL regenerado: entityArticles(entityId, page, limit) → ArticlesResult
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.
Problema
A página
/entidades/[id]mostra 0 artigos ao clicar em qualquer entidade canônica (Q... / dgb_...). Causa:getEntityArticlesfiltrava porentityCanonicalno Typesense, mas o campoentity_canonicaldos documentos ainda não foi populado (o reprocessamento está pendente, bloqueado em infra#198).Solução
Novo resolver
entityArticles(entityId, page, limit)que consultanews_entities → newsdiretamente no Postgres, sem depender do Typesense:_ENTITY_ARTICLES_SQL: CTE deduplicaunique_id(news_entities pode ter várias linhas por artigo), ordena porpublished_at DESC, pagina comLIMIT/OFFSET. Total via subquery.PostgresDatasource.get_entity_articles(): retorna(list[NewsRecord], total_count).EntityQuery.entity_articles: mapeiaNewsRecord → Article; clamp defensivo empage/limit.O campo
entityCanonicale o Typesense não são afetados — o reprocessamento ainda vai acontecer; este fix é independente.Teste
{ entityArticles(entityId: "Q5933752", page: 1, limit: 5) { found articles { uniqueId title publishedAt } } }Confirmado em staging que retorna 7 artigos para Q5933752 (antes retornava 0 via filter.entityCanonical).
Checklist
make docs-schema)actions.tspara usargetArticlesByEntity(Postgres) quandocanonicalIdpresente🤖 Generated with Claude Code