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

Reports Update: Adds a query that produces gtfs rt and vp completeness #3424

Merged
merged 1 commit into from
Aug 23, 2024
Merged
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
4 changes: 3 additions & 1 deletion warehouse/models/mart/gtfs_quality/_mart_gtfs_quality.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: 2

models:

- name: fct_dailytrip_updates_vehicle_positions_completeness
description: |
A daily model of how many trips had either a single trip update or a single vehicle position message
- name: fct_daily_rt_feed_validation_notices
description: |
A daily model of validation notices found per feed. Data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{ config(materialized='table') }}

WITH map AS (
SELECT *
FROM {{ ref('int_gtfs_quality__organization_dataset_map') }}
WHERE public_customer_facing_or_regional_subfeed_fixed_route
),
st as (SELECT * from {{ ref('fct_scheduled_trips') }}),
ot as (SELECT * from {{ ref('fct_observed_trips') }}),
fct_daily_trip_updates_vehicle_positions_completeness AS (
SELECT
organization_name,
organization_itp_id,
organization_source_record_id,
DATE_TRUNC(st.service_date, DAY) AS service_date,

-- Percentage of trips with TU messages
(CAST(SUM(IF(ot.tu_num_distinct_message_ids > 0, 1, 0)) AS FLOAT64) / NULLIF(COUNT(*), 0)) * 100 AS percent_of_trips_with_TU_messages,

-- Percentage of trips with VP messages
(CAST(SUM(IF(ot.vp_num_distinct_message_ids > 0, 1, 0)) AS FLOAT64) / NULLIF(COUNT(*), 0)) * 100 AS percent_of_trips_with_VP_messages,
NULLIF(COUNT(*), 0) as scheduled_trips,
FROM st
LEFT JOIN ot
ON st.trip_instance_key = ot.trip_instance_key
LEFT JOIN map
ON map.schedule_feed_key = st.feed_key
WHERE st.service_date < DATE_TRUNC(CURRENT_DATE('America/Los_Angeles'), DAY)
AND organization_itp_id IS NOT NULL
GROUP BY 1, 2, 3, 4
)

SELECT *
FROM fct_daily_trip_updates_vehicle_positions_completeness
Loading