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

Better Handle Centreline Cleaning #53

Open
cczhu opened this issue Jul 14, 2021 · 0 comments
Open

Better Handle Centreline Cleaning #53

cczhu opened this issue Jul 14, 2021 · 0 comments

Comments

@cczhu
Copy link
Contributor

cczhu commented Jul 14, 2021

Traffic Prophet reads from prj_volume.tp_daily_volumes to generate CountMatch predictions. The source table is prj_volume.centreline_volumes, which uses an arterycode to centreline geo_id mapping to map FLOW counts to the centreline. A recent refresh of this table uses a mapping with centreline segments not defined in gis.centreline, so we generated the following temporary matview:

CREATE MATERIALIZED VIEW prj_volume.tp_daily_volumes_clean
TABLESPACE pg_default
AS
 WITH distinct_centrelines AS (
         SELECT DISTINCT tp_daily_volumes_1.centreline_id
           FROM prj_volume.tp_daily_volumes tp_daily_volumes_1
        ), available_centrelines AS (
         SELECT distinct_centrelines.centreline_id
           FROM distinct_centrelines
             JOIN gis.centreline ON distinct_centrelines.centreline_id::numeric = centreline.geo_id
        )
 SELECT available_centrelines.centreline_id,
    tp_daily_volumes.direction,
    tp_daily_volumes.count_year,
    tp_daily_volumes.count_date,
    tp_daily_volumes.daily_count
   FROM available_centrelines
     JOIN prj_volume.tp_daily_volumes USING (centreline_id)
  ORDER BY available_centrelines.centreline_id, tp_daily_volumes.direction, tp_daily_volumes.count_year, tp_daily_volumes.count_date
WITH DATA;

ALTER TABLE prj_volume.tp_daily_volumes_clean
    OWNER TO prj_volume_admins;

COMMENT ON MATERIALIZED VIEW prj_volume.tp_daily_volumes_clean
    IS 'Version of tp_daily_volumes_clean without centreline IDs that do not exist in gis.centreline.';

to read data into Traffic Prophet. Annoyingly I didn't manage to document this entire process during my offboarding.

If the problem can be corrected quickly, this issue is to remove tp_daily_volumes_clean and ensure all documentation in docs uses tp_daily_volumes rather than _clean. If the problem cannot be corrected quickly, this issue is to add the script above to input_data/flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant