feature: produtiza trend detection — DAG + job + migration#190
Merged
Conversation
Adiciona compute_entity_trending DAG (6h), job package trend_detection/ com signals.py adaptado, scorer.py copiado (NDCG=1.0) e persist.py com UPSERT idempotente em entity_trending_scores. Migration 025 cria a tabela com coluna volume_ratio (exibida no portal).
Migration 024 estava no working tree mas não estava commitada, causando sequence gap no validator de integração.
O framework de testes de integração (_apply_all_migrations) aplica TODAS as migrations CONCURRENTLY numa Phase 2 antes de rodar as demais. Como 024 é detectada como concurrent (contém o token CONCURRENTLY), ela era aplicada logo após 009 — antes das migrations 021/022 que criam news_entities e entity_edges. As tabelas são novas, então não há risco de lock em produção. IF NOT EXISTS já garante idempotência.
O scanner _find_concurrent_migrations() faz match simples de string no texto completo do arquivo (incluindo comentários). A migration 024 tinha a palavra no comentário explicativo, causando sua classificação como concurrent e aplicação em Phase 2 — antes das migrations 021/022 que criam as tabelas.
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
entity_trending_scoresvia migration 025 (incluivolume_ratiopara o portal)src/data_platform/jobs/trend_detection/com signals.py, scorer.py (NDCG@10=1.0) e persist.pycompute_entity_trendingrodando 4× ao dia (schedule:0 */6 * * *)Test plan
pytest tests/unit/jobs/test_trend_detection_scorer.py— verdepytest tests/unit/jobs/test_trend_detection_persist.py— verdepytest tests/unit/dags/test_compute_entity_trending.py— verdedb-migrate.yamlSELECT COUNT(*) FROM entity_trending_scores;🤖 Generated with Claude Code