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

Ability to view temp records in the crashes list and also soft-delete them #1495

Merged
merged 24 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8bfb5ee
update metadata permissions etc
roseeichelmann Jul 31, 2024
fbd5886
add is_deleted = false where clause
roseeichelmann Jul 31, 2024
4efedfa
soft delete mutations
roseeichelmann Jul 31, 2024
771726d
handle soft delete
roseeichelmann Jul 31, 2024
1c59d64
default to private dr false on temp record creation
roseeichelmann Jul 31, 2024
b1a4eb1
add/remove permissions for these tables
roseeichelmann Aug 1, 2024
9fc34eb
create a separate soft delete mutation for person records
roseeichelmann Aug 1, 2024
e53e78f
pass useremail
roseeichelmann Aug 1, 2024
0479b04
loop thru each unit and soft delete all the person records, then dele…
roseeichelmann Aug 1, 2024
b551433
fix dom warning
roseeichelmann Aug 1, 2024
c1f9c75
dont actually need to query person id here
roseeichelmann Aug 1, 2024
121a69c
update comment
roseeichelmann Aug 1, 2024
c1e6764
format these
roseeichelmann Aug 1, 2024
d90f9d5
remove is_temp_record to fix inconsistent metadata this doesnt exist …
roseeichelmann Aug 1, 2024
72fad68
add permissions
roseeichelmann Aug 1, 2024
4a9180a
adjust all other views to filter out soft deleted records
roseeichelmann Aug 1, 2024
337fbd1
add record locator to fatalities view, filter out soft deleted records
roseeichelmann Aug 1, 2024
58d2748
use record locator instead of crash id
roseeichelmann Aug 1, 2024
e7bafc2
wow there was such a better more simple way to do this i had an enlig…
roseeichelmann Aug 1, 2024
52c42a8
toggle off successful record alert whenever temp record is deleted
roseeichelmann Aug 1, 2024
7f16699
query is_temp_record
roseeichelmann Aug 2, 2024
8eaa702
remove secondary address is missing
roseeichelmann Aug 2, 2024
378d0cb
different message from missing crash diagram if a temp record
roseeichelmann Aug 2, 2024
a1b32e8
remove the this cannot be undone message
roseeichelmann Aug 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ create or replace view person_injury_metrics_view as (
left join
public.crashes as crashes
on units.crash_id = crashes.id
where people.is_deleted = false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updating all of these views to filter out soft deleted records

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i made a todo that we should index those columns 👍

);

create or replace view unit_injury_metrics_view as
Expand Down Expand Up @@ -215,6 +216,7 @@ create or replace view unit_injury_metrics_view as
left join
person_injury_metrics_view
on units.id = person_injury_metrics_view.unit_id
where units.is_deleted = false
group by
units.id
);
Expand Down Expand Up @@ -320,6 +322,7 @@ create or replace view crash_injury_metrics_view as
left join
person_injury_metrics_view
on crashes.id = person_injury_metrics_view.crash_id
where crashes.is_deleted = false
group by
crashes.id,
crashes.crash_id
Expand Down Expand Up @@ -419,6 +422,7 @@ left join
left join
lookups.injry_sev_lkp
on lookups.injry_sev_lkp.id = crash_injury_metrics_view.crash_injry_sev_id
where crashes.is_deleted = false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crashes list view only has records that havent been soft deleted now

order by id asc;

create view locations_list_view as (
Expand Down Expand Up @@ -561,7 +565,7 @@ left join lateral (
left join
lookups.collsn_lkp
on public.crashes.fhe_collsn_id = lookups.collsn_lkp.id
where crashes.crash_timestamp >= (now() - '5 years'::interval)::date
where crashes.is_deleted = false and crashes.crash_timestamp >= (now() - '5 years'::interval)::date
union all
select
aab.form_id as crash_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ select
people.id as person_id,
crashes.id as crash_id,
crashes.crash_id as cris_crash_id,
crashes.record_locator,
units.id as unit_id,
CONCAT_WS(' ', people.prsn_first_name, people.prsn_mid_name, people.prsn_last_name) as victim_name,
TO_CHAR(crashes.crash_timestamp at time zone 'US/Central', 'yyyy') AS year,
Expand Down Expand Up @@ -48,4 +49,4 @@ crashes.engineering_area
people
left join units on people.unit_id = units.id
left join crashes on units.crash_id = crashes.id
where crashes.in_austin_full_purpose = true AND people.prsn_injry_sev_id = 4 AND crashes.private_dr_fl = false;
where crashes.in_austin_full_purpose = true AND people.prsn_injry_sev_id = 4 AND crashes.private_dr_fl = false AND crashes.is_deleted = false;
117 changes: 4 additions & 113 deletions atd-vzd/metadata/databases/default/tables/public_crashes_cris.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,63 +53,6 @@ array_relationships:
name: units_edits
schema: public
insert_permissions:
- role: editor
permission:
check: {}
columns:
- active_school_zone_fl
- at_intrsct_fl
- case_id
- crash_speed_limit
- crash_timestamp
- created_by
- cris_schema_version
- fhe_collsn_id
- intrsct_relat_id
- investigat_agency_id
- investigator_narrative
- is_temp_record
- latitude
- light_cond_id
- longitude
- medical_advisory_fl
- obj_struck_id
- onsys_fl
- private_dr_fl
- road_constr_zone_fl
- road_constr_zone_wrkr_fl
- rpt_block_num
- rpt_city_id
- rpt_cris_cnty_id
- rpt_hwy_num
- rpt_rdwy_sys_id
- rpt_ref_mark_dir
- rpt_ref_mark_dist_uom
- rpt_ref_mark_offset_amt
- rpt_road_part_id
- rpt_sec_block_num
- rpt_sec_hwy_num
- rpt_sec_rdwy_sys_id
- rpt_sec_road_part_id
- rpt_sec_street_desc
- rpt_sec_street_name
- rpt_sec_street_pfx
- rpt_sec_street_sfx
- rpt_street_desc
- rpt_street_name
- rpt_street_pfx
- rpt_street_sfx
- rr_relat_fl
- schl_bus_fl
- surf_cond_id
- surf_type_id
- thousand_damage_fl
- toll_road_fl
- traffic_cntl_id
- txdot_rptable_fl
- updated_by
- wthr_cond_id
comment: ""
- role: vz-admin
permission:
check: {}
Expand Down Expand Up @@ -168,7 +111,7 @@ insert_permissions:
- wthr_cond_id
comment: ""
select_permissions:
- role: editor
- role: vz-admin
permission:
columns:
- active_school_zone_fl
Expand Down Expand Up @@ -229,64 +172,12 @@ select_permissions:
- wthr_cond_id
filter: {}
comment: ""
update_permissions:
- role: vz-admin
permission:
columns:
- active_school_zone_fl
- at_intrsct_fl
- case_id
- crash_id
- crash_speed_limit
- crash_timestamp
- created_at
- created_by
- cris_schema_version
- fhe_collsn_id
- id
- intrsct_relat_id
- investigat_agency_id
- investigator_narrative
- is_temp_record
- latitude
- light_cond_id
- longitude
- medical_advisory_fl
- obj_struck_id
- onsys_fl
- private_dr_fl
- road_constr_zone_fl
- road_constr_zone_wrkr_fl
- rpt_block_num
- rpt_city_id
- rpt_cris_cnty_id
- rpt_hwy_num
- rpt_rdwy_sys_id
- rpt_ref_mark_dir
- rpt_ref_mark_dist_uom
- rpt_ref_mark_offset_amt
- rpt_road_part_id
- rpt_sec_block_num
- rpt_sec_hwy_num
- rpt_sec_rdwy_sys_id
- rpt_sec_road_part_id
- rpt_sec_street_desc
- rpt_sec_street_name
- rpt_sec_street_pfx
- rpt_sec_street_sfx
- rpt_street_desc
- rpt_street_name
- rpt_street_pfx
- rpt_street_sfx
- rr_relat_fl
- schl_bus_fl
- surf_cond_id
- surf_type_id
- thousand_damage_fl
- toll_road_fl
- traffic_cntl_id
- txdot_rptable_fl
- updated_at
- is_deleted
- updated_by
- wthr_cond_id
filter: {}
check: {}
comment: ""
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,42 @@ select_permissions:
- role: editor
permission:
columns:
- cris_fatality_count
- fatality_count
- law_enf_fatality_count
- nonincap_injry_count
- non_injry_count
- poss_injry_count
- sus_serious_injry_count
- unkn_injry_count
- vz_fatality_count
- years_of_life_lost
- active_school_zone_fl
- address_primary
- address_secondary
- at_intrsct_fl
- has_no_cris_coordinates
- in_austin_full_purpose
- is_manual_geocode
- onsys_fl
- private_dr_fl
- road_constr_zone_fl
- rr_relat_fl
- schl_bus_fl
- toll_road_fl
- case_id
- collsn_desc
- council_district
- crash_date_ct
- crash_day_of_week
- crash_id
- crash_injry_sev_desc
- crash_injry_sev_id
- crash_speed_limit
- crash_time_ct
- crash_timestamp
- cris_fatality_count
- est_comp_cost_crash_based
- fatality_count
- has_no_cris_coordinates
- id
- in_austin_full_purpose
- intrsct_relat_id
- light_cond_id
- obj_struck_id
- traffic_cntl_id
- wthr_cond_id
- is_manual_geocode
- latitude
- longitude
- address_primary
- address_secondary
- case_id
- collsn_desc
- crash_date_ct
- crash_day_of_week
- crash_injry_sev_desc
- crash_time_ct
- law_enf_fatality_count
- light_cond_id
- location_id
- longitude
- non_injry_count
- nonincap_injry_count
- obj_struck_id
- onsys_fl
- poss_injry_count
- private_dr_fl
- record_locator
- road_constr_zone_fl
- rpt_block_num
- rpt_sec_block_num
- rpt_sec_street_name
Expand All @@ -77,57 +69,58 @@ select_permissions:
- rpt_street_name
- rpt_street_pfx
- rpt_street_sfx
- crash_timestamp
- rr_relat_fl
- schl_bus_fl
- sus_serious_injry_count
- toll_road_fl
- tot_injry_count
- traffic_cntl_id
- unkn_injry_count
- vz_fatality_count
- wthr_cond_id
- years_of_life_lost
filter: {}
allow_aggregations: true
comment: ""
- role: readonly
permission:
columns:
- cris_fatality_count
- fatality_count
- law_enf_fatality_count
- nonincap_injry_count
- non_injry_count
- poss_injry_count
- sus_serious_injry_count
- unkn_injry_count
- vz_fatality_count
- years_of_life_lost
- active_school_zone_fl
- address_primary
- address_secondary
- at_intrsct_fl
- has_no_cris_coordinates
- in_austin_full_purpose
- is_manual_geocode
- onsys_fl
- private_dr_fl
- road_constr_zone_fl
- rr_relat_fl
- schl_bus_fl
- toll_road_fl
- case_id
- collsn_desc
- council_district
- crash_date_ct
- crash_day_of_week
- crash_id
- crash_injry_sev_desc
- crash_injry_sev_id
- crash_speed_limit
- crash_time_ct
- crash_timestamp
- cris_fatality_count
- est_comp_cost_crash_based
- fatality_count
- has_no_cris_coordinates
- id
- in_austin_full_purpose
- intrsct_relat_id
- light_cond_id
- obj_struck_id
- traffic_cntl_id
- wthr_cond_id
- is_manual_geocode
- latitude
- longitude
- address_primary
- address_secondary
- case_id
- collsn_desc
- crash_date_ct
- crash_day_of_week
- crash_injry_sev_desc
- crash_time_ct
- law_enf_fatality_count
- light_cond_id
- location_id
- longitude
- non_injry_count
- nonincap_injry_count
- obj_struck_id
- onsys_fl
- poss_injry_count
- private_dr_fl
- record_locator
- road_constr_zone_fl
- rpt_block_num
- rpt_sec_block_num
- rpt_sec_street_name
Expand All @@ -136,7 +129,16 @@ select_permissions:
- rpt_street_name
- rpt_street_pfx
- rpt_street_sfx
- crash_timestamp
- rr_relat_fl
- schl_bus_fl
- sus_serious_injry_count
- toll_road_fl
- tot_injry_count
- traffic_cntl_id
- unkn_injry_count
- vz_fatality_count
- wthr_cond_id
- years_of_life_lost
filter: {}
allow_aggregations: true
comment: ""
Expand All @@ -150,6 +152,7 @@ select_permissions:
- non_injry_count
- poss_injry_count
- sus_serious_injry_count
- tot_injry_count
- unkn_injry_count
- vz_fatality_count
- years_of_life_lost
Expand Down
Loading