From 112af25cd04bb34a57c66ed7e67bd3320ee2ed16 Mon Sep 17 00:00:00 2001 From: Rafael Carvalho Pinheiro <74972217+pixuimpou@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:15:12 -0300 Subject: [PATCH] =?UTF-8?q?[Hotfix]=20Deduplica=20dados=20de=20servico=20n?= =?UTF-8?q?as=20views=20da=20Ja=C3=A9=20(#109)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Deduplica ids dos serviços * add change log * link pr --- .../br_rj_riodejaneiro_bilhetagem/flows.py | 2 +- .../dashboard_bilhetagem_jae/CHANGELOG.md | 5 +++++ .../view_integracao.sql | 18 ++++++++++++++++-- .../view_passageiros_hora.sql | 16 +++++++++++++++- .../view_passageiros_tile_hora.sql | 16 +++++++++++++++- 5 files changed, 52 insertions(+), 5 deletions(-) diff --git a/pipelines/migration/br_rj_riodejaneiro_bilhetagem/flows.py b/pipelines/migration/br_rj_riodejaneiro_bilhetagem/flows.py index 0d8d606a..a1035a58 100644 --- a/pipelines/migration/br_rj_riodejaneiro_bilhetagem/flows.py +++ b/pipelines/migration/br_rj_riodejaneiro_bilhetagem/flows.py @@ -2,7 +2,7 @@ """ Flows for br_rj_riodejaneiro_bilhetagem -DBT: 2024-07-17 2 +DBT: 2024-07-17 3 """ from copy import deepcopy diff --git a/queries/models/dashboard_bilhetagem_jae/CHANGELOG.md b/queries/models/dashboard_bilhetagem_jae/CHANGELOG.md index 49d2bf97..f391c72e 100644 --- a/queries/models/dashboard_bilhetagem_jae/CHANGELOG.md +++ b/queries/models/dashboard_bilhetagem_jae/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog - dashboard_bilhetagem_jae +## [1.0.1] - 2024-07-17 + +### Corrigido +- Deduplica ids dos serviços (https://github.com/prefeitura-rio/pipelines_rj_smtr/pull/109) + ## [1.0.0] - 2024-06-11 ### Adicionado diff --git a/queries/models/dashboard_bilhetagem_jae/view_integracao.sql b/queries/models/dashboard_bilhetagem_jae/view_integracao.sql index 08481f88..601916d1 100644 --- a/queries/models/dashboard_bilhetagem_jae/view_integracao.sql +++ b/queries/models/dashboard_bilhetagem_jae/view_integracao.sql @@ -1,4 +1,18 @@ -WITH dados_filtrados AS ( +WITH servicos AS ( + SELECT + * EXCEPT(rn) + FROM + ( + SELECT + *, + ROW_NUMBER() OVER (PARTITION BY id_servico_jae ORDER BY data_inicio_vigencia) AS rn + FROM + {{ ref("servicos") }} + ) + WHERE + rn = 1 +), +dados_filtrados AS ( SELECT i.data, i.hora, @@ -11,7 +25,7 @@ WITH dados_filtrados AS ( FROM {{ ref("integracao") }} i LEFT JOIN - {{ ref("servicos") }} s + servicos s USING(id_servico_jae) WHERE data >= "2024-02-24" diff --git a/queries/models/dashboard_bilhetagem_jae/view_passageiros_hora.sql b/queries/models/dashboard_bilhetagem_jae/view_passageiros_hora.sql index 298ea4b2..2afe00d0 100644 --- a/queries/models/dashboard_bilhetagem_jae/view_passageiros_hora.sql +++ b/queries/models/dashboard_bilhetagem_jae/view_passageiros_hora.sql @@ -1,4 +1,18 @@ -- depends_on: {{ ref('view_passageiros_tile_hora') }} +WITH servicos AS ( + SELECT + * EXCEPT(rn) + FROM + ( + SELECT + *, + ROW_NUMBER() OVER (PARTITION BY id_servico_jae ORDER BY data_inicio_vigencia) AS rn + FROM + {{ ref("servicos") }} + ) + WHERE + rn = 1 +) SELECT p.data, p.hora, @@ -20,5 +34,5 @@ SELECT FROM {{ ref("passageiros_hora") }} p LEFT JOIN - {{ ref("servicos") }} s + servicos s USING(id_servico_jae) \ No newline at end of file diff --git a/queries/models/dashboard_bilhetagem_jae/view_passageiros_tile_hora.sql b/queries/models/dashboard_bilhetagem_jae/view_passageiros_tile_hora.sql index 5fb393b3..35269163 100644 --- a/queries/models/dashboard_bilhetagem_jae/view_passageiros_tile_hora.sql +++ b/queries/models/dashboard_bilhetagem_jae/view_passageiros_tile_hora.sql @@ -1,3 +1,17 @@ +WITH servicos AS ( + SELECT + * EXCEPT(rn) + FROM + ( + SELECT + *, + ROW_NUMBER() OVER (PARTITION BY id_servico_jae ORDER BY data_inicio_vigencia) AS rn + FROM + {{ ref("servicos") }} + ) + WHERE + rn = 1 +) SELECT p.data, p.hora, @@ -18,5 +32,5 @@ SELECT FROM {{ ref("passageiros_tile_hora") }} p LEFT JOIN - {{ ref("servicos") }} s + servicos s USING(id_servico_jae) \ No newline at end of file