From f448d9c6ac679643adff7d21ea97062e48e62d97 Mon Sep 17 00:00:00 2001 From: Rodrigo Cunha <66736583+eng-rodrigocunha@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:57:34 -0300 Subject: [PATCH] Ajusta GTFS para Domingo CNU (#224) * commit inicial * fix treatment * Altera flow * Incorpora changelog * ajusta changelog * atualiza changelog --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../br_rj_riodejaneiro_gtfs/CHANGELOG.md | 7 +++++++ .../br_rj_riodejaneiro_gtfs/flows.py | 2 +- ...em_servico_sentido_atualizado_aux_gtfs.sql | 16 +++++++++++--- .../gtfs/ordem_servico_trips_shapes_gtfs.sql | 21 +++++++++++++++---- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/pipelines/migration/br_rj_riodejaneiro_gtfs/CHANGELOG.md b/pipelines/migration/br_rj_riodejaneiro_gtfs/CHANGELOG.md index 4fb5b7e4..7bd51e2c 100644 --- a/pipelines/migration/br_rj_riodejaneiro_gtfs/CHANGELOG.md +++ b/pipelines/migration/br_rj_riodejaneiro_gtfs/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog - gtfs +## [1.1.1] - 2024-09-13 + +### Alterado + +- Inserido ajuste para o tipo_os `CNU` com feed_start_date `2024-08-16` considerar o planejamento do GTFS de sábado no domingo. Afetado o modelo `ordem_servico_trips_shapes_gtfs.sql` (https://github.com/prefeitura-rio/pipelines_rj_smtr/pull/224) +- Ajustado tratamento dos modelos `ordem_servico_sentido_atualizado_aux_gtfs.sql` e `ordem_servico_trips_shapes_gtfs.sql` em razão da apuração por faixa horária `DATA_SUBSIDIO_V9_INICIO` (https://github.com/prefeitura-rio/pipelines_rj_smtr/pull/224) + ## [1.1.0] - 2024-09-11 ### Alterado diff --git a/pipelines/migration/br_rj_riodejaneiro_gtfs/flows.py b/pipelines/migration/br_rj_riodejaneiro_gtfs/flows.py index 20086e29..006e994f 100644 --- a/pipelines/migration/br_rj_riodejaneiro_gtfs/flows.py +++ b/pipelines/migration/br_rj_riodejaneiro_gtfs/flows.py @@ -2,7 +2,7 @@ """ Flows for gtfs -DBT: 2024-09-10 +DBT: 2024-09-13 """ from prefect import Parameter, case, task diff --git a/queries/models/gtfs/ordem_servico_sentido_atualizado_aux_gtfs.sql b/queries/models/gtfs/ordem_servico_sentido_atualizado_aux_gtfs.sql index 13a5e105..90876c6a 100644 --- a/queries/models/gtfs/ordem_servico_sentido_atualizado_aux_gtfs.sql +++ b/queries/models/gtfs/ordem_servico_sentido_atualizado_aux_gtfs.sql @@ -78,6 +78,16 @@ LEFT JOIN USING (feed_version, servico) WHERE - distancia_planejada != 0 - AND distancia_total_planejada != 0 - AND (partidas != 0 OR partidas IS NULL) \ No newline at end of file + ( + ( + feed_start_date < '{{ var("DATA_SUBSIDIO_V9_INICIO") }}' + AND + ( + distancia_planejada != 0 + AND distancia_total_planejada != 0 + AND (partidas != 0 OR partidas IS NULL) + ) + ) + OR + feed_start_date >= '{{ var("DATA_SUBSIDIO_V9_INICIO") }}' + ) \ No newline at end of file diff --git a/queries/models/gtfs/ordem_servico_trips_shapes_gtfs.sql b/queries/models/gtfs/ordem_servico_trips_shapes_gtfs.sql index e3fe9e8f..cc0eb97d 100644 --- a/queries/models/gtfs/ordem_servico_trips_shapes_gtfs.sql +++ b/queries/models/gtfs/ordem_servico_trips_shapes_gtfs.sql @@ -54,7 +54,8 @@ WITH AND o.servico = t.trip_short_name AND (o.tipo_dia = t.tipo_dia - OR (o.tipo_dia = "Ponto Facultativo" AND t.tipo_dia = "Dia Útil")) + OR (o.tipo_dia = "Ponto Facultativo" AND t.tipo_dia = "Dia Útil") + OR (o.feed_start_date = "2024-08-16" AND o.tipo_os = "CNU" AND o.tipo_dia = "Domingo" AND t.tipo_dia = "Sabado")) -- Domingo CNU AND ((o.sentido IN ("I", "C") AND t.direction_id = "0") OR (o.sentido = "V" AND t.direction_id = "1")) @@ -217,7 +218,19 @@ LEFT JOIN -- rj-smtr-dev.gtfs.ordem_servico_faixa_horaria AS fh USING (feed_version, feed_start_date, tipo_os, tipo_dia, servico) -{% if is_incremental() -%} WHERE - feed_start_date = '{{ var("data_versao_gtfs") }}' -{% endif -%} \ No newline at end of file +{% if is_incremental() -%} + feed_start_date = '{{ var("data_versao_gtfs") }}' AND +{% endif -%} + ( + ( + feed_start_date >= '{{ var("DATA_SUBSIDIO_V9_INICIO") }}' + AND + ( + fh.quilometragem != 0 + AND (fh.partidas != 0 OR fh.partidas IS NULL) + ) + ) + OR + feed_start_date < '{{ var("DATA_SUBSIDIO_V9_INICIO") }}' + ) \ No newline at end of file