From c28cfd9e43c0a15d58de47a431842703806ed127 Mon Sep 17 00:00:00 2001 From: gabrielwol <80077912+gabrielwol@users.noreply.github.com> Date: Fri, 26 Jul 2024 18:29:59 +0000 Subject: [PATCH] #868, #879 update views --- ...create-view-volumes_15min_atr_filtered.sql | 37 ++++--------------- ...create-view-volumes_15min_mvt_filtered.sql | 4 +- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/volumes/miovision/sql/views/create-view-volumes_15min_atr_filtered.sql b/volumes/miovision/sql/views/create-view-volumes_15min_atr_filtered.sql index 9d7844b6c..fbb2f71db 100644 --- a/volumes/miovision/sql/views/create-view-volumes_15min_atr_filtered.sql +++ b/volumes/miovision/sql/views/create-view-volumes_15min_atr_filtered.sql @@ -38,34 +38,11 @@ CREATE VIEW miovision_api.volumes_15min_atr_filtered AS ( mmm.exit_dir ); ---test: 0.2 s with primary key -SELECT * -FROM miovision_api.volumes_15min_atr_filtered -WHERE - intersection_uid = 6 - AND classification_uid = 1 - AND datetime_bin = '2024-06-25 12:00:00' - AND leg <> LEFT(dir, 1); +ALTER VIEW miovision_api.volumes_15min_atr_filtered OWNER TO miovision_admins; ---DR i0627 test using new view ---41s for original, 1:06 for view (1.3M rows) -SELECT - volumes.intersection_uid, - date_trunc('hour', volumes.datetime_bin) AS datetime_bin, - volumes.leg, - volumes.dir, - classifications.classification, - SUM(volumes.volume) AS volume -FROM miovision_api.volumes_15min_atr_filtered AS volumes -INNER JOIN miovision_api.classifications USING (classification_uid) -WHERE - volumes.classification_uid NOT IN (2, 7) - AND volumes.datetime_bin >= '2024-01-01' - AND volumes.datetime_bin < '2024-05-22' - AND volumes.intersection_uid IN (76, 88, 81, 85, 84, 87, 75, 83, 86, 49, 80, 36) -GROUP BY - volumes.intersection_uid, - classifications.classification, - date_trunc('hour', volumes.datetime_bin), - volumes.leg, - volumes.dir; \ No newline at end of file +COMMENT ON VIEW miovision_api.volumes_15min_atr_filtered IS E'' +'A ATR style transformation of miovision_api.volumes_15min_mvt with anomalous_ranges labeled ' +'''do-not-use'' or ''questionable'' filtered out, unacceptable_gaps anti-joined, +and only common (>0.05%) movements (`intersection_movements`) included.'; + +GRANT SELECT ON TABLE miovision_api.volumes_15min_atr_filtered TO bdit_humans; \ No newline at end of file diff --git a/volumes/miovision/sql/views/create-view-volumes_15min_mvt_filtered.sql b/volumes/miovision/sql/views/create-view-volumes_15min_mvt_filtered.sql index 828b04af8..c6307f1f7 100644 --- a/volumes/miovision/sql/views/create-view-volumes_15min_mvt_filtered.sql +++ b/volumes/miovision/sql/views/create-view-volumes_15min_mvt_filtered.sql @@ -30,8 +30,10 @@ CREATE OR REPLACE VIEW miovision_api.volumes_15min_mvt_filtered AS ( AND un.datetime_bin IS NULL ); +ALTER VIEW miovision_api.volumes_15min_mvt_filtered OWNER TO miovision_admins; + COMMENT ON VIEW miovision_api.volumes_15min_mvt_filtered IS E'' -'miovision_api.volumes_15min with anomalous_ranges labeled ' +'TMC style 15-minute Miovision volume view with anomalous_ranges labeled ' '''do-not-use'' or ''questionable'' filtered out, unacceptable_gaps anti-joined, and only common (>0.05%) movements (`intersection_movements`) included.';