Skip to content

Conversation

@roseeichelmann
Copy link
Contributor

@roseeichelmann roseeichelmann commented Dec 9, 2025

Associated issues

Closes cityofaustin/atd-data-tech#6972

Testing

URL to test:
Local

Steps to test:

  1. Start ur local db, apply migrations and metadata
  2. Next you need to run these commands to trigger the function that updates address_display and then refresh the locations materialized view that also will need to update w the new address_display
UPDATE crashes
SET address_display = generate_crash_address(
    at_intrsct_fl,
    rpt_block_num,
    rpt_street_pfx,
    rpt_street_name,
    rpt_street_sfx,
    rpt_hwy_num,
    rpt_hwy_sfx,
    rpt_rdwy_sys_id,
    rpt_road_part_id,
    rpt_sec_block_num,
    rpt_sec_street_pfx,
    rpt_sec_street_name,
    rpt_sec_street_sfx,
    rpt_sec_hwy_num,
    rpt_sec_hwy_sfx,
    rpt_sec_rdwy_sys_id,
    rpt_sec_road_part_id
);

REFRESH MATERIALIZED VIEW location_crashes_view;
  1. Go to the crashes list page map and click on the different points to the view the popups with the pretty addresses
  2. Toggle the crashes list view, make sure you click the RESET button and then use the address search bar
  3. Click on a crash to go to its details page. Toggle a crash from not on intersection to intersection to see the difference in how a crash is formatted
  4. Edit the address for a crash by clicking on the address header and test trying to add duplicate suffix/prefixes, for example putting RD in the suffix and in the street name text boxes. See that on save the duplicate RDs wont show on the crash header ✨ '
  5. Go to a crash with a highway number that has roadway system "LOCAL ROAD/STREET (STREET, ROAD, AVE., BLVD. PL. ...... etc etc" such as http://localhost:3002/editor/crashes/20967702 and make sure the roadway system label just been shortened to LOCAL ROAD, so the address should be something like N LOCAL ROAD 1
  6. Go look at all the places the address_display is used, so on the fatalities map view, all the list pages, also on the EMS details page under "Possible CR3 people matches"
  7. On locations details page, scroll down to the map and make sure that all the popups have the address displayed as expected, for both CR3 and NON-CR3 crashes
  8. Test down migration

Ship list

  • Check migrations for any conflicts with latest migrations in main branch
  • Confirm Hasura role permissions for necessary access
  • Code reviewed
  • Product manager approved

@roseeichelmann roseeichelmann added the WIP Work in progress label Dec 9, 2025
@netlify
Copy link

netlify bot commented Dec 9, 2025

Deploy Preview for atd-vze-staging ready!

Name Link
🔨 Latest commit 38acff5
🔍 Latest deploy log https://app.netlify.com/projects/atd-vze-staging/deploys/693b1fd15e1a620008ea2333
😎 Deploy Preview https://deploy-preview-1908--atd-vze-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@johnclary johnclary left a comment

Choose a reason for hiding this comment

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

Wow, these addresses look soo good! Thank you for taking care of all of this—there are so many parts of our codebase to update and refactor as a result of this mega improvement 🙌

I think my feedback is pretty minor. I did not run any of our ETLs, but i'll probably do a test run of the CRIS import and Socrata exporter just to be safe.

id
address_primary
address_secondary
address_display
Copy link
Member

Choose a reason for hiding this comment

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

We're going to need to update this dataset once we launch:

https://data.austintexas.gov/Transportation-and-Mobility/Austin-Crash-Report-Data-Crash-Level-Records/y2wy-tgr5/about_data

Image

I'll make a note in the launch checklist and possibly open it as a separate issue

CREATE INDEX idx_crashes_address_display ON crashes(address_display);

-- Function to format highway addresses
CREATE OR REPLACE FUNCTION format_highway_address(
Copy link
Member

Choose a reason for hiding this comment

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

I love having these two separate functions for highways vs streets. Really easy to follow what's happening 🚀

Copy link
Member

Choose a reason for hiding this comment

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

agreed!

-- Only add if not a duplicate of previous (case-insensitive)
IF UPPER(current_part) != UPPER(prev_part) THEN
deduped_parts := array_append(deduped_parts, current_part);
END IF;
Copy link
Member

Choose a reason for hiding this comment

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

This works so well—nice!



-- Main function to generate complete crash address
CREATE OR REPLACE FUNCTION generate_crash_address(
Copy link
Member

Choose a reason for hiding this comment

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

Not a strongly held opinion, but I think it'd be fine to simplify this function signature to accept a crash record, rather than itemizing every single column input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

im gonna leave it as is 😅

return `${crash.address_primary ? crash.address_primary : ""} ${
crash.address_secondary ? "& " + crash.address_secondary : ""
}`;
};
Copy link
Member

Choose a reason for hiding this comment

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

🎉

Copy link
Member

@chiaberry chiaberry left a comment

Choose a reason for hiding this comment

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

This is such a giant quality improvement and so many cases to handle! I am still reviewing and wrapping my head around the SQL, but I came across this crash 21182993 and the address says "TODD LN & E BEN WHITE BLVD EB BLVD" and I dont know if it slipped through the formatting or the input is to blame.

@netlify
Copy link

netlify bot commented Jan 7, 2026

Deploy Preview for atd-vze-staging ready!

Name Link
🔨 Latest commit 67a236f
🔍 Latest deploy log https://app.netlify.com/projects/atd-vze-staging/deploys/695fe3fa10b6180008df17fe
😎 Deploy Preview https://deploy-preview-1908--atd-vze-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@roseeichelmann
Copy link
Contributor Author

@chiaberry unfortunately we are only really able to handle repeats that come right after each other like RD RD. so in the case you shared the input is just so messed up and its gonna have to be manually fixed

@roseeichelmann
Copy link
Contributor Author

Alright i updated my migration to replace atd_txdot_locations with locations (so happy we finally got around to this!) and made sure my migration comes last. this should be good to go now!

Copy link
Member

@chiaberry chiaberry left a comment

Choose a reason for hiding this comment

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

Rose this is such a massive undertaking and huge quality improvement. 🥇

Comment on lines 205 to 206
- created_at
- created_at
Copy link
Contributor

@mddilley mddilley Jan 7, 2026

Choose a reason for hiding this comment

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

@roseeichelmann I'm still reviewing but it looks some column names were duplicated probably through the merging. I know how tedious the metadata can get!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ugh so frustrating i have no idea how that happened! thank you for catching this and your thorough review of the code 🙏

Copy link
Contributor

@mddilley mddilley left a comment

Choose a reason for hiding this comment

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

I'll approve this after the metadata column duplicates that I noted are removed, but this is amazing! Love the steps to dedupe and also the highway vs. streets treatment. Easy to follow and looks ready for any future adjustments if CRIS changes anything up on us. 🚀

Also a big upgrade to have less address processing logic in the front end code. 🍄 🙌

Comment on lines +302 to +306
-- Drop old columns

ALTER TABLE crashes DROP COLUMN address_primary CASCADE;

ALTER TABLE crashes DROP COLUMN address_secondary CASCADE;
Copy link
Contributor

Choose a reason for hiding this comment

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

i had forgotten that these weren't CRIS columns at all - goodbye old address columns! 👋

Copy link
Contributor

@mateoclarke mateoclarke left a comment

Choose a reason for hiding this comment

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

Looks great Rose. Monster up migration but such a huge improvement. I bet this was tedious but it look so much better! 🚀

Copy link
Contributor

@mddilley mddilley left a comment

Choose a reason for hiding this comment

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

🚢 ✨✨✨

Copy link
Member

@johnclary johnclary left a comment

Choose a reason for hiding this comment

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

Test steps check out and I tested the CRIS import and socrata export ETLs. Everything looks great. Thanks, Rose! 🚢 🚢 🚢 🚢

@frankhereford frankhereford dismissed their stale review January 8, 2026 17:39

Rose has addressed the issues! Thank you!

@roseeichelmann roseeichelmann merged commit 89d6db4 into main Jan 8, 2026
8 checks passed
@roseeichelmann roseeichelmann deleted the rose/fix_address_formatting branch January 8, 2026 17:57
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

Successfully merging this pull request may close these issues.

Cleanup crash address formatting

6 participants