Skip to content

Commit

Permalink
[HOTFIX] Bilhetagem - Corrige serviço nas tabelas agregadas de GPS (#317
Browse files Browse the repository at this point in the history
)

* adiciona coluna servico nas tabelas da jae

* adiciona changelog

* Corrige CHANGELOG.md

* altera serviços para os dados da jae

* adiciona colunas novas no schema

* altera changelog

* correções validação

* corrigir referencia das colunas do gps_validador

* corrigir nome das colunas gps_validador

* corrige alias

* corrige servico

* corrige servico

* corrige servico brt

* corrige id linha

* correcao ordem_pagamento

* corrige typo changelog
  • Loading branch information
pixuimpou authored May 20, 2024
1 parent 25cb57e commit 0051a05
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
3 changes: 2 additions & 1 deletion models/br_rj_riodejaneiro_bilhetagem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## [1.2.1] - 2024-05-20

### Corrigido
- Altera alias da tabela `linha_sem_ressarcimento` no modelo `transacao.sql`
- Altera alias da tabela `linha_sem_ressarcimento` no modelo `transacao.sql` (https://github.com/prefeitura-rio/queries-rj-smtr/pull/317)
- Corrige select servico no modelo `ordem_pagamento_servico_operador_dia.sql` ((https://github.com/prefeitura-rio/queries-rj-smtr/pull/317)

## [1.2.0] - 2024-05-20

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ SELECT
o.id_operadora,
o.operadora,
o.id_servico_jae,
o.servico,
o.servico_jae,
o.descricao_servico_jae,
o.id_ordem_pagamento,
o.id_ordem_ressarcimento,
o.quantidade_transacao_debito,
Expand Down
2 changes: 1 addition & 1 deletion models/br_rj_riodejaneiro_bilhetagem/transacao.sql
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ ON
LEFT JOIN
{{ ref("staging_linha_sem_ressarcimento") }} lsr
ON
t.cd_linha = l.id_linha
t.cd_linha = lsr.id_linha
WHERE
lsr.id_linha IS NULL
AND DATE(data_transacao) >= "2023-07-17"
12 changes: 6 additions & 6 deletions models/dashboard_bilhetagem_implantacao_jae/gps_agregado_brt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ WITH gps_agregado AS (
primeiro_datetime_gps,
MINUTE
) + 1 AS qtde_min_entre_a_prim_e_ultima_transmissao,
COUNT(*) OVER (PARTITION BY servico, id_validador) AS qtde_registros_gps,
COUNT(DISTINCT FORMAT_TIMESTAMP("%F %H:%M", datetime_gps)) OVER (PARTITION BY servico, id_validador) AS qtde_min_distintos_houve_transmissao,
COUNT(*) OVER (PARTITION BY servico_jae, id_validador) AS qtde_registros_gps,
COUNT(DISTINCT FORMAT_TIMESTAMP("%F %H:%M", datetime_gps)) OVER (PARTITION BY servico_jae, id_validador) AS qtde_min_distintos_houve_transmissao,
SUM(
CASE
WHEN latitude != 0 AND longitude != 0 AND latitude IS NOT NULL AND longitude IS NOT NULL THEN 1
ELSE 0 END
) OVER (PARTITION BY servico, id_validador) AS qtde_registros_gps_georreferenciados,
ROW_NUMBER() OVER (PARTITION BY servico, id_validador ORDER BY datetime_gps) AS rn
) OVER (PARTITION BY servico_jae, id_validador) AS qtde_registros_gps_georreferenciados,
ROW_NUMBER() OVER (PARTITION BY servico_jae, id_validador ORDER BY datetime_gps) AS rn
FROM
(
SELECT
*,
MIN(datetime_gps) OVER (PARTITION BY servico, id_validador) AS primeiro_datetime_gps,
MAX(datetime_gps) OVER (PARTITION BY servico, id_validador) AS ultimo_datetime_gps,
MIN(datetime_gps) OVER (PARTITION BY servico_jae, id_validador) AS primeiro_datetime_gps,
MAX(datetime_gps) OVER (PARTITION BY servico_jae, id_validador) AS ultimo_datetime_gps,
ROW_NUMBER() OVER (PARTITION BY id_transmissao_gps ORDER BY datetime_captura DESC) AS rn
FROM
{{ ref("gps_validador") }}
Expand Down
12 changes: 6 additions & 6 deletions models/dashboard_bilhetagem_implantacao_jae/gps_agregado_vlt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ WITH gps_agregado AS (
primeiro_datetime_gps,
MINUTE
) + 1 AS qtde_min_entre_a_prim_e_ultima_transmissao,
COUNT(*) OVER (PARTITION BY servico, id_validador) AS qtde_registros_gps,
COUNT(DISTINCT FORMAT_TIMESTAMP("%F %H:%M", datetime_gps)) OVER (PARTITION BY servico, id_validador) AS qtde_min_distintos_houve_transmissao,
COUNT(*) OVER (PARTITION BY servico_jae, id_validador) AS qtde_registros_gps,
COUNT(DISTINCT FORMAT_TIMESTAMP("%F %H:%M", datetime_gps)) OVER (PARTITION BY servico_jae, id_validador) AS qtde_min_distintos_houve_transmissao,
SUM(
CASE
WHEN latitude != 0 AND longitude != 0 AND latitude IS NOT NULL AND longitude IS NOT NULL THEN 1
ELSE 0 END
) OVER (PARTITION BY servico, id_validador) AS qtde_registros_gps_georreferenciados,
ROW_NUMBER() OVER (PARTITION BY servico, id_validador ORDER BY datetime_gps) AS rn
) OVER (PARTITION BY servico_jae, id_validador) AS qtde_registros_gps_georreferenciados,
ROW_NUMBER() OVER (PARTITION BY servico_jae, id_validador ORDER BY datetime_gps) AS rn
FROM
(
SELECT
*,
MIN(datetime_gps) OVER (PARTITION BY servico, id_validador) AS primeiro_datetime_gps,
MAX(datetime_gps) OVER (PARTITION BY servico, id_validador) AS ultimo_datetime_gps,
MIN(datetime_gps) OVER (PARTITION BY servico_jae, id_validador) AS primeiro_datetime_gps,
MAX(datetime_gps) OVER (PARTITION BY servico_jae, id_validador) AS ultimo_datetime_gps,
ROW_NUMBER() OVER (PARTITION BY id_transmissao_gps ORDER BY datetime_captura DESC) AS rn
FROM
{{ ref("gps_validador") }}
Expand Down

0 comments on commit 0051a05

Please sign in to comment.