refactor & test homepage alerts - #3338
Merged
Merged
Conversation
This reverts commit c2c5a8c.
joshlarson
approved these changes
Jul 15, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Scope
Asana Ticket: 📈 Speed up alerts call on the homepage
Implementation
Showing alerts on the homepage means we have to fetch all alerts, group them by applicable mode and accessibility effect, and fetch all the relating routes and stops so we could render the right route pills or stop links. When starting from an empty cache it's a lot of data fetching!
This PR does a couple things:
Alerts.Repo.all/1calls a function that callsAlerts.Sort.sort/1. For the homepage, we don't need any alert sorting - so I added a function that fetches all current alerts, without the sorting.Task.async_stream/3to manage fetching many routes or stops in parallel. Another improvement over the original code is that it doesn't break if theRoutes.RepoandStops.Repocalls returnnil(which is a valid case).How to test
I used
Util.log_duration/3to measure how long it takes to render the alerts tab HTML content given a list of alerts. All numbers are inmsmainbranch, no cache - 8338.736main, everything cached - 6.147