Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtra serviços de GPS com base no GTFS para dash GPS SPPO 8 dias #108

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ models:
br_rj_riodejaneiro_rdo:
+materialized: view
+schema: br_rj_riodejaneiro_rdo
dashboard_sppo_gps_8_dias:
+materialized: view
+schema: dashboard_sppo_gps_8_dias
21 changes: 21 additions & 0 deletions models/dashboard_sppo_gps_8_dias/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Dados para o dashboard "GPS dos ônibus"
* Versão: 0.1
* Data de início: 13/07/2023


## 1. Resumo

Este modelo tem por objetivo tratar os dados de GPS para que eles sejam exibidos no dashboard de "[GPS dos ônibus](https://app.powerbi.com/view?r=eyJrIjoiZTljNzIxNTAtN2QxZS00OTczLThjMjUtNWY1NjdjZWVlODZmIiwidCI6IjkwNzI2YWVlLWQwMmMtNDlmZS05ODlmLTQ1ZGVmM2QwNjlkYyJ9)".


## 2. Etapas

### 2.1 Importação
O modelo utilizou dados das seguintes tabelas:

rj-smtr.dashboards.gps_sppo_8_dias

rj-smtr.projeto_subsidio_sppo.viagem_planejada

### 2.2 Transformações
Os dados da tabela gps_sppo_8_dias foram filtrados de forma que o resultado final incluisse apenas aqueles serviços presentes na tabela viagem_planejada.
21 changes: 21 additions & 0 deletions models/dashboard_sppo_gps_8_dias/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2

models:
- name: sppo_gps_8_dias
description: "sppo_gps_8_dias"
columns:
- name: id_veiculo
description: "Número do veículo configurado no equipamento."
- name: servico
description: "Código do serviço."
- name: latitude
description: "Latitude do veículo no momento da captura do sinal de GPS."
- name: longitude
description: "Longitude do veículo no momento da captura do sinal de GPS."
- name: data
description: "Data de captura do sinal de GPS no formato yyyy-mm-dd."
- name: hora
description: "Horário de captura do sinal de GPS no formato HH:mm:ss."
- name: timestamp_gps
description: "Timestamp de captura do sinal de GPS no formato yyyy-mm-dd T HH:mm:ss."

32 changes: 32 additions & 0 deletions models/dashboard_sppo_gps_8_dias/sppo_gps_8_dias.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* Criar a tabela para ser usada no dashboard sobre GPS 8 dias*/

WITH
gtfs AS (
SELECT DISTINCT
route_short_name
FROM
`rj-smtr.br_rj_riodejaneiro_sigmob.routes_desaninhada`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

atualizar com o sigmob v2

WHERE
agency_id IN ('22002', '22003', '22004', '22005')),
gps AS (
SELECT
id_veiculo,
servico,
latitude,
longitude,
DATE(timestamp_gps) AS data,
TIME(timestamp_gps) AS hora,
timestamp_gps
FROM
rj-smtr.br_rj_riodejaneiro_veiculos.gps_sppo
WHERE
data between date_sub(current_date(), interval 8 day) and CURRENT_DATE() )
SELECT
gps.*
FROM
gps
JOIN
gtfs
ON gps.servico = route_short_name


Loading