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

hotfix(ScheduleDirection): fix line diagram for routes with repeated stops #1760

Merged
merged 4 commits into from
Sep 28, 2023

Conversation

thecristen
Copy link
Collaborator

No ticket - fixing a bug on dev with the 217 & 120 bus route schedule pages.

Background

The recent PR updated how stops were being fetched for the line diagram, but came with corrected data that broke the line diagram code on at least two pages. It turns out the recursive code that parses the stops to draw the branches on the line diagram assumes that each stop ID is unique, which is assuredly not the case for the 217 and 120 routes, each of which repeat at least one stop along its route.

Highlighted changes

The approach I took here was to just not compute the stop tree for pages for a ferry or bus route. We don't need it - these either don't have line diagrams or have simple lines that won't branch.

Backend

  • Consolidated the two places that were computing a stop tree into one function
  • Adjusted that function to return different data depending on the route type - allowing us to send nil stop tree

Frontend

  • Refactored many components to work with a null stop tree.
  • Use the list of stops from the backend if the stop tree is null

Fixed 217 route

image


General checks

  • Are the changes organized into self-contained commits with descriptive and well-formatted commit messages? This is a good practice that can facilitate easier reviews.
  • Testing. Do the changes include relevant passing updates to tests? This includes updating screenshots. Preferably tests are run locally to verify that there are no test failures created by these changes, before opening a PR.
  • Tech debt. Have you checked for tech debt you can address in the area you're working in? This can be a good time to address small issues, or create Asana tickets for larger issues.

New endpoints, or non-trivial changes to current endpoints

  • Have we load-tested any new pages or internal API endpoints that will receive significant traffic? See load testing docs
  • If this change involves routes, does it work correctly with pertinent "unusual" routes such as the combined Green Line, Silver Line, Foxboro commuter rail, and single-direction bus routes like the 170?

@thecristen thecristen requested a review from a team as a code owner September 27, 2023 19:42
@thecristen thecristen requested review from EmmaSimon and kotva006 and removed request for EmmaSimon September 27, 2023 19:42
{/* Draw circles for each stop */
routeStopList.map((routeStop, index) => (
// eslint-disable-next-line react/no-array-index-key
<Stop key={`${index}-${routeStop.id}`} stopId={routeStop.id} />
Copy link
Contributor

Choose a reason for hiding this comment

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

We really shouldn't be using indexes as keys, for the underlying list items could change, but the index does not. Is the id not unique here? Is there some other way to get a unique id? (Like name-id-zone)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The routeStop.id is not guaranteed to be unique amongst the list of stops. Because of this edge case where stops are repeated along the route. But maybe I can add a number to each item in the list and use that as the key...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kotva006 I've pushed an update to change this.

Copy link
Contributor

@kotva006 kotva006 left a comment

Choose a reason for hiding this comment

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

Looks good

@thecristen thecristen merged commit 83b02a5 into master Sep 28, 2023
20 checks passed
@thecristen thecristen deleted the cbj/line-diagram-bus-fix branch September 28, 2023 19: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.

2 participants