-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
…te the units and crash for the crash id
@@ -231,7 +232,7 @@ const CreateCrashRecord = ({ client }) => { | |||
id="hf-case-id" | |||
name="hf-case-id" | |||
placeholder="Enter Case ID..." | |||
autocomplete="off" | |||
autoComplete="off" |
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.
fixes dom warning
@@ -193,6 +193,7 @@ const CreateCrashRecord = ({ client }) => { | |||
created_by: userEmail, | |||
cris_schema_version: "2023", | |||
is_temp_record: true, | |||
private_dr_fl: false, |
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.
default to private_dr_fl = false
on temp record creation, meaning the crash will show up in our socrata totals and in the crashes list page, etc
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.
perfect. glad you mentioned Socrata—I think we should the is_temp_record
column to public datasets. i'll add it to the todo list :)
@@ -419,6 +419,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 |
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.
crashes list view only has records that havent been soft deleted now
@@ -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 |
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.
updating all of these views to filter out soft deleted records
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.
i made a todo that we should index those columns 👍
@@ -3,7 +3,7 @@ export const createCrashDataMap = isTempRecord => { | |||
{ | |||
title: "Details", | |||
fields: { | |||
crash_id: { | |||
record_locator: { |
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.
now the temp records wont have an empty space here on the crash details page
@@ -5,13 +5,13 @@ export const fatalityGridTableColumns = { | |||
label_table: "Year", | |||
type: "Int", | |||
}, | |||
cris_crash_id: { | |||
record_locator: { |
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.
also to show the temp crash ids of temp records
@@ -147,15 +135,15 @@ const CreateCrashRecordTable = ({ crashesData, loading, error }) => { | |||
</Link> | |||
</td> | |||
<td>{item.case_id}</td> | |||
<td>{item.crash_timestamp}</td> | |||
<td>{formatDateTimeString(item.crash_timestamp)}</td> |
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.
previously these werent formatted and were showing up as ugly ISO strings
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.
nice!
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.
@roseeichelmann this looks great and works great—so nice to have this missing piece in place.
I have a tiny change request to fix that delete confirmation text.
These other things can happily be out of scope, but I want to ask if you would address them in this PR and/or give your feedback:
- I don't like this text that says
SECONDARY ADDRESS MISSING
. I think it would be better to not render anything if the secondary address isnull
.
- It would be nice to change the text that appears in the crash diagram card. For temp records, the text can say "Crash diagrams are not available for user-created crash records" 👇
- Lastly—I'm not sure about this one—I noticed that people records do not get created unless the injury severity was fatal or serious. But units do get created no matter what. See this example, where we have three units but only two person records, because the fatal and serious injury count were both
0
for unit 2:
I think ideally we should create a person record with no injury in these cases. Right? I also wonder what we're doing in production today...
I'm happy to open separate issues for these tasks ☝️
} | ||
} | ||
update_people_cris( | ||
where: { units_cri: { crash_id: { _eq: $recordId } } } |
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.
awesome to see this nested where
! i'm going to rename the relationship units_cri
to units_cris
in a forthcoming PR that branches from here. that's an artifact of Hasura trying to guess at pluralization 🤖
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.
i was gonna point out the cri thing and ask if we should rename but i forgot, glad you pointed it out!
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.
multiple cri = cris. this whole thing is hilarious to me. Thanks for the laugh, Hasura! 😄 And, thanks y'all for fixing. 🚀
primary_key: true, | ||
searchable: true, | ||
sortable: true, | ||
label_search: "Search by Crash ID", | ||
label_table: "Crash ID", | ||
type: "Int", | ||
type: "String", |
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.
ah yes, we should index record_locator
as well. i'm tracking that ✅
@@ -193,6 +193,7 @@ const CreateCrashRecord = ({ client }) => { | |||
created_by: userEmail, | |||
cris_schema_version: "2023", | |||
is_temp_record: true, | |||
private_dr_fl: false, |
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.
perfect. glad you mentioned Socrata—I think we should the is_temp_record
column to public datasets. i'll add it to the todo list :)
const openModalDelete = crashId => { | ||
setDeleteId(crashId); | ||
const openModalDelete = recordId => { | ||
setDeleteId(recordId); | ||
toggleModalDelete(); |
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.
@@ -147,15 +135,15 @@ const CreateCrashRecordTable = ({ crashesData, loading, error }) => { | |||
</Link> | |||
</td> | |||
<td>{item.case_id}</td> | |||
<td>{item.crash_timestamp}</td> | |||
<td>{formatDateTimeString(item.crash_timestamp)}</td> |
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.
nice!
Here's the issue to fix the 404 handler: cityofaustin/atd-data-tech#18479 |
@johnclary i addressed all your requested changes, as for your last point, not adding any people unless they are injuries/fatalities is how it currently works in production. i think the vz team truly just cares about injuries and fatalities for temp records and it was a conscious choice to only create ppl records for that. plus, there could be 5 people in a unit and if none of them had any injuries or fatalities and we just auto added 1 person to the unit that wouldnt make much sense either? |
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.
🚢 🚢 🚢 🚢 🚢 🚢 🚢 🚢
)} | ||
<h2 className="h2 mb-3">{`${primaryAddress ? primaryAddress : ""} ${ | ||
secondaryAddress ? "& " + secondaryAddress : "" | ||
}`}</h2> |
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.
✨
@roseeichelmann great points—I agree with you wrt to those person records 🙏 |
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.
I tested all of the steps, and it is all working as expected. So nice to see these soft deletes!!! This PR really shows off the record locator too! Good stuff!! 🚢 😎 🙌
(isTempRecord ? ( | ||
<CardBody> | ||
<p> | ||
Crash diagrams are not available for user-created crash records. |
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.
i like this detail!
// }); | ||
// }; | ||
/** | ||
* Soft deletes the temporary crash and all its associated unit and people records |
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.
thanks for being more specific about the types of records affected in this comment. the old comment threw me for a loop!
variables: { recordId: deleteId, updatedBy: userEmail }, | ||
}) | ||
.then(() => { | ||
setSuccessfulNewRecordId(null); |
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.
at first i was confused about why this needs to be set to null
but now i see that this makes the green alert go away if it happens to be there after previously adding a temp record. 👍
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.
yup you got it!
Associated issues
Closes cityofaustin/atd-data-tech#18429
Testing
URL to test:
Local
Steps to test:
is_deleted
columns updated totrue
.Ship list