diff --git a/events/construction/sql/create-function-get_lanesaffected_sum.sql b/events/construction/sql/create-function-get_lanesaffected_sum.sql index 24a564552..612e24188 100644 --- a/events/construction/sql/create-function-get_lanesaffected_sum.sql +++ b/events/construction/sql/create-function-get_lanesaffected_sum.sql @@ -4,6 +4,7 @@ CREATE OR REPLACE FUNCTION itsc_factors.get_lanesaffected_sums(input_string text) RETURNS TABLE ( + lap_descriptions text[], lane_open_auto integer, lane_closed_auto integer, lane_open_bike integer, @@ -26,6 +27,7 @@ BEGIN -- Iterate over the list and aggregate sums for each code RETURN QUERY SELECT + ARRAY_AGG(lane_status) AS lap_descriptions, COALESCE(SUM(lane_open) FILTER (WHERE mode = 'Car'), 0)::int AS lane_open_auto, COALESCE(SUM(lane_closed) FILTER (WHERE mode = 'Car'), 0)::int AS lane_closed_auto, COALESCE(SUM(lane_open) FILTER (WHERE mode = 'Bike'), 0)::int AS lane_open_bike, diff --git a/events/construction/sql/create-view-rodars_locations.sql b/events/construction/sql/create-view-rodars_locations.sql index fde991a30..557bf2613 100644 --- a/events/construction/sql/create-view-rodars_locations.sql +++ b/events/construction/sql/create-view-rodars_locations.sql @@ -54,7 +54,9 @@ SELECT CASE iil.centreline_id WHEN 0 THEN NULL ELSE iil.centreline_id END AS centreline_id, centreline_latest.geom AS centreline_geom, iil.geom AS issue_geom, - iil.linear_name_id, + CASE iil.linear_name_id WHEN 0 THEN NULL ELSE iil.linear_name_id END AS linear_name_id, + iil.lanesaffectedpattern, + lap.lap_descriptions, lap.lane_open_auto, lap.lane_closed_auto, lap.lane_open_bike, @@ -79,6 +81,7 @@ LEFT JOIN itsc_factors.roadclosuretype_old ON iil.roadclosuretype::numeric::integer = itsc_factors.roadclosuretype_old.code, LATERAL ( SELECT + get_lanesaffected_sums.lap_descriptions, get_lanesaffected_sums.lane_open_auto, get_lanesaffected_sums.lane_closed_auto, get_lanesaffected_sums.lane_open_bike,