feature: analytics DAY — generate_series preenche lacunas diárias#23
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
Quando granularity=DAY, _AGENCY_ANALYTICS_DAY_SQL usa generate_series para garantir que todos os dias do intervalo aparecem no resultado mesmo sem artigos (article_count=0 via COALESCE). MONTH e WEEK continuam usando DATE_TRUNC.
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.
Summary
_AGENCY_ANALYTICS_DAY_SQLcomgenerate_seriespara garantir que todos os dias do intervalo aparecem quandogranularity=DAYarticle_count=0viaCOALESCEem vez de simplesmente sumirem do resultadoMONTHeWEEKcontinuam usando o SQL existente comDATE_TRUNCparametrizadoTestAgencyAnalyticsDayGapFillverificam: seleção correta do SQL por granularidade e comportamento do gap-fillTest plan
test_day_granularity_usa_generate_series— confirma que DAY usa a SQL comgenerate_seriestest_month_granularity_usa_date_trunc— confirma que MONTH usa o SQL comDATE_TRUNC($1test_day_retorna_zeros_para_dias_sem_artigos— valida dias comarticle_count=0e métricasNone