Skip to content

Commit

Permalink
corrige tratamento de viagens (#234)
Browse files Browse the repository at this point in the history
* corrige tratamento de viagens em do

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* comenta registros_historico no schema de btr_gps

* corrige query de busca de shapes em aux_registro_status_trajeto

* descomenta registros_historico do eschema de brt_gps

* atualiza changelog

* corrige filtro da cte shapes em aux_regisros_status_trajeto

* corrige referencias e dependencia de subsidio_data_versao_efetiva

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove order by data

* corrige changelog

* corrige changelog sobre referencias de tabelas

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 17, 2024
1 parent 4fbeca6 commit e0cfb90
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pipelines/migration/projeto_subsidio_sppo/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
Flows for projeto_subsidio_sppo
DBT: 2024-09-16
DBT: 2024-09-17
"""

from prefect import Parameter, case, task
Expand Down
10 changes: 10 additions & 0 deletions queries/models/projeto_subsidio_sppo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog - projeto_subsidio_sppo

## [9.0.2] - 2024-09-17

### Corrigido

- corrigidas as referencias a tabela `gps_sppo` em `aux_registro_status_trajeto` (https://github.com/prefeitura-rio/pipelines_rj_smtr/pull/234)

### Alterado

- Alterada a consulta por shapes em `aux_registro_status_trajeto` para buscar o feed_start_date do particionamento da tabela shapes_geom em `data_versao_efetiva`(https://github.com/prefeitura-rio/pipelines_rj_smtr/pull/234)

## [9.0.1] - 2024-09-11

### Alterado
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-- depends_on: {{ ref('subsidio_data_versao_efetiva') }}
{% if execute %}
{% set result = run_query("SELECT feed_start_date FROM " ~ ref('subsidio_data_versao_efetiva') ~ " WHERE data BETWEEN DATE_SUB(DATE('" ~ var("run_date") ~ "'), INTERVAL 2 DAY) AND DATE_SUB(DATE('" ~ var("run_date") ~ "'), INTERVAL 1 DAY)") %}
{% set feed_start_dates = result.columns[0].values() %}
{% endif %}

{% if var("run_date") == "2024-05-05" %}
-- Apuração "Madonna · The Celebration Tour in Rio"
{% set gps_interval = 7 %}
Expand Down Expand Up @@ -27,7 +33,8 @@ with gps as (
date_sub(date("{{ var("run_date") }}"), interval 1 day) as data_operacao
{% endif %}
from
`rj-smtr.br_rj_riodejaneiro_veiculos.gps_sppo` g -- {{ ref('gps_sppo') }} g
-- `rj-smtr.br_rj_riodejaneiro_veiculos.gps_sppo` g
{{ ref('gps_sppo') }} g
where (
data between date_sub(date("{{ var("run_date") }}"), interval 1 day) and date("{{ var("run_date") }}")
)
Expand Down Expand Up @@ -116,7 +123,8 @@ with gps as (
ST_GEOGPOINT(longitude, latitude) posicao_veiculo_geo,
date_sub(date("{{ var("run_date") }}"), interval 1 day) as data_operacao
from
`rj-smtr.br_rj_riodejaneiro_veiculos.gps_sppo` g -- {{ ref('gps_sppo') }} g
-- `rj-smtr.br_rj_riodejaneiro_veiculos.gps_sppo` g
{{ ref('gps_sppo') }} g
where (
data between date_sub(date("{{ var("run_date") }}"), interval 1 day) and date("{{ var("run_date") }}")
)
Expand All @@ -133,8 +141,9 @@ shapes AS (
*
FROM
{{ ref("shapes_geom_gtfs") }}
-- rj-smtr.gtfs.shapes_geom
WHERE
date_sub(date("{{ var("run_date") }}"), interval 1 day) BETWEEN feed_start_date AND feed_end_date
feed_start_date IN ('{{ feed_start_dates|join("', '") }}')
),
-- 3. Deduplica viagens planejadas
viagem_planejada AS (
Expand Down

0 comments on commit e0cfb90

Please sign in to comment.