-
Notifications
You must be signed in to change notification settings - Fork 4
Adds more fields and filters to the locations list #1973
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
Open
johnclary
wants to merge
14
commits into
main
Choose a base branch
from
john/26710-loc-list-filters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cbe46e7
adds more columns to locations list vie
johnclary 310bdd3
adds more filter cards to locations list
johnclary 305365a
wip
johnclary 623fafd
add dropdown menu shadow
johnclary 4d2f61d
add street level filters and use yes/no formatter
johnclary d50a2e5
add street level labels
johnclary 86a18d6
add high inj net filter
johnclary 1884c2b
🤖 Export database views for john/26710-loc-list-filters
5c4a289
remove a todo
johnclary 66b2a79
remove a comment
johnclary af6a0d6
move col defs around and add to deets card
johnclary 294a9ac
add council distr filter
johnclary fe769bc
add apd sector and remove location id
johnclary 69e4984
handle passing Barray of strings into gql filter
johnclary File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
database/migrations/default/1771530231604_locations_list_view_more_cols/down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| CREATE OR REPLACE VIEW locations_list_view AS WITH cr3_comp_costs AS ( | ||
| SELECT | ||
| crashes_list_view.location_id, | ||
| sum(crashes_list_view.est_comp_cost_crash_based) AS cr3_comp_costs_total | ||
| FROM crashes_list_view | ||
| WHERE crashes_list_view.crash_timestamp > (now() - '5 years'::interval) | ||
| GROUP BY crashes_list_view.location_id | ||
| ), | ||
|
|
||
| cr3_crash_counts AS ( | ||
| SELECT | ||
| crashes.location_id, | ||
| count(crashes.location_id) AS crash_count | ||
| FROM crashes | ||
| WHERE | ||
| crashes.private_dr_fl = false | ||
| AND crashes.location_id IS NOT null | ||
| AND crashes.crash_timestamp > (now() - '5 years'::interval) | ||
| GROUP BY crashes.location_id | ||
| ), | ||
|
|
||
| non_cr3_crash_counts AS ( | ||
| SELECT | ||
| atd_apd_blueform.location_id, | ||
| count(atd_apd_blueform.location_id) AS crash_count, | ||
| count(atd_apd_blueform.location_id) * 10000 AS noncr3_comp_costs_total | ||
| FROM atd_apd_blueform | ||
| WHERE | ||
| atd_apd_blueform.location_id IS NOT null | ||
| AND atd_apd_blueform.is_deleted = false | ||
| AND atd_apd_blueform.case_timestamp > (now() - '5 years'::interval) | ||
| GROUP BY atd_apd_blueform.location_id | ||
| ) | ||
|
|
||
| SELECT | ||
| locations.location_id, | ||
| locations.location_name, | ||
| locations.council_district, | ||
| locations.location_group, | ||
| coalesce( | ||
| cr3_comp_costs.cr3_comp_costs_total + non_cr3_crash_counts.noncr3_comp_costs_total, | ||
| 0::bigint | ||
| ) AS total_est_comp_cost, | ||
| coalesce( | ||
| cr3_crash_counts.crash_count, 0::bigint | ||
| ) AS cr3_crash_count, | ||
| coalesce( | ||
| non_cr3_crash_counts.crash_count, 0::bigint | ||
| ) AS non_cr3_crash_count, | ||
| coalesce(cr3_crash_counts.crash_count, 0::bigint) | ||
| + coalesce(non_cr3_crash_counts.crash_count, 0::bigint) AS crash_count | ||
| FROM locations | ||
| LEFT JOIN cr3_crash_counts ON locations.location_id::text = cr3_crash_counts.location_id | ||
| LEFT JOIN | ||
| non_cr3_crash_counts | ||
| ON locations.location_id::text = non_cr3_crash_counts.location_id::text | ||
| LEFT JOIN cr3_comp_costs ON locations.location_id::text = cr3_comp_costs.location_id; |
40 changes: 40 additions & 0 deletions
40
database/migrations/default/1771530231604_locations_list_view_more_cols/up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| drop view locations_list_view; | ||
| create or replace view locations_list_view as | ||
| WITH cr3_comp_costs AS ( | ||
| SELECT crashes_list_view.location_id, | ||
| sum(crashes_list_view.est_comp_cost_crash_based) AS cr3_comp_costs_total | ||
| FROM crashes_list_view | ||
| WHERE crashes_list_view.crash_timestamp > (now() - '5 years'::interval) | ||
| GROUP BY crashes_list_view.location_id | ||
| ), cr3_crash_counts AS ( | ||
| SELECT crashes.location_id, | ||
| count(crashes.location_id) AS crash_count | ||
| FROM crashes | ||
| WHERE crashes.private_dr_fl = false AND crashes.location_id IS NOT NULL AND crashes.crash_timestamp > (now() - '5 years'::interval) | ||
| GROUP BY crashes.location_id | ||
| ), non_cr3_crash_counts AS ( | ||
| SELECT atd_apd_blueform.location_id, | ||
| count(atd_apd_blueform.location_id) AS crash_count, | ||
| count(atd_apd_blueform.location_id) * 10000 AS noncr3_comp_costs_total | ||
| FROM atd_apd_blueform | ||
| WHERE atd_apd_blueform.location_id IS NOT NULL AND atd_apd_blueform.is_deleted = false AND atd_apd_blueform.case_timestamp > (now() - '5 years'::interval) | ||
| GROUP BY atd_apd_blueform.location_id | ||
| ) | ||
| SELECT locations.location_id, | ||
| locations.location_name, | ||
| locations.council_districts, | ||
| locations.location_group, | ||
| locations.is_signalized, | ||
| locations.signal_eng_areas, | ||
| locations.area_eng_areas, | ||
| locations.street_levels, | ||
| locations.apd_sectors, | ||
| locations.is_hin, | ||
| COALESCE(cr3_comp_costs.cr3_comp_costs_total + non_cr3_crash_counts.noncr3_comp_costs_total, 0::bigint) AS total_est_comp_cost, | ||
| COALESCE(cr3_crash_counts.crash_count, 0::bigint) AS cr3_crash_count, | ||
| COALESCE(non_cr3_crash_counts.crash_count, 0::bigint) AS non_cr3_crash_count, | ||
| COALESCE(cr3_crash_counts.crash_count, 0::bigint) + COALESCE(non_cr3_crash_counts.crash_count, 0::bigint) AS crash_count | ||
| FROM locations | ||
| LEFT JOIN cr3_crash_counts ON locations.location_id::text = cr3_crash_counts.location_id | ||
| LEFT JOIN non_cr3_crash_counts ON locations.location_id::text = non_cr3_crash_counts.location_id::text | ||
| LEFT JOIN cr3_comp_costs ON locations.location_id::text = cr3_comp_costs.location_id; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| -- Most recent migration: database/migrations/default/1767430748998_crash_address_display_trigger/up.sql | ||
| -- Most recent migration: database/migrations/default/1771445809119_update_location_crashes_view/up.sql | ||
|
|
||
| DROP MATERIALIZED VIEW IF EXISTS location_crashes_view; | ||
|
|
||
| CREATE MATERIALIZED VIEW location_crashes_view AS SELECT | ||
| crashes.record_locator, | ||
| crashes.cris_crash_id, | ||
| crashes.id AS crash_pk, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the view bot missed these changes because Rose's PR came in after it. |
||
| 'CR3'::text AS type, | ||
| crashes.location_id, | ||
| crashes.case_id, | ||
|
|
@@ -87,6 +88,7 @@ UNION ALL | |
| SELECT | ||
| null::text AS record_locator, | ||
| aab.form_id AS cris_crash_id, | ||
| null::integer AS crash_pk, | ||
| 'NON-CR3'::text AS type, | ||
| aab.location_id, | ||
| aab.case_id::text AS case_id, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,14 @@ | ||
| import { locationColumns } from "./locationColumns"; | ||
|
|
||
| export const locationCardColumns = [ | ||
| locationColumns.location_id, | ||
| locationColumns.cr3_crash_count, | ||
| locationColumns.non_cr3_crash_count, | ||
| locationColumns.total_est_comp_cost, | ||
| locationColumns.street_level, | ||
| locationColumns.area_eng_areas, | ||
| locationColumns.signal_eng_areas, | ||
| locationColumns.is_signalized, | ||
| locationColumns.council_districts, | ||
| locationColumns.is_hin, | ||
| locationColumns.apd_sectors | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import Link from "next/link"; | ||
| import { ColDataCardDef } from "@/types/types"; | ||
| import { LocationsListRow } from "@/types/locationsList"; | ||
| import { locationColumns } from "@/configs/locationColumns"; | ||
|
|
||
| export const locationsListViewColumns: ColDataCardDef<LocationsListRow>[] = [ | ||
| { | ||
|
|
@@ -17,6 +18,12 @@ export const locationsListViewColumns: ColDataCardDef<LocationsListRow>[] = [ | |
| path: "location_name", | ||
| label: "Location", | ||
| sortable: true, | ||
| style: { | ||
| maxWidth: "30rem", | ||
| overflow: "hidden", | ||
| textOverflow: "ellipsis", | ||
| whiteSpace: "nowrap", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| }, | ||
| }, | ||
| { | ||
| path: "cr3_crash_count", | ||
|
|
@@ -28,4 +35,11 @@ export const locationsListViewColumns: ColDataCardDef<LocationsListRow>[] = [ | |
| label: "Non-CR3 crashes", | ||
| sortable: true, | ||
| }, | ||
| locationColumns.area_eng_areas, | ||
| locationColumns.signal_eng_areas, | ||
| locationColumns.is_signalized, | ||
| locationColumns.council_districts, | ||
| { ...locationColumns.street_level, defaultHidden: true }, | ||
| { ...locationColumns.apd_sectors, defaultHidden: true }, | ||
| { ...locationColumns.is_hin, defaultHidden: true }, | ||
| ]; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so nice having this diff to review!