-
Notifications
You must be signed in to change notification settings - Fork 56
Add alternate route names to itin description #1406
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
Conversation
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.
Should we extract the alternateRouteNames extraction code to a new method?
const alternateRouteNames = | ||
leg.alternateRoutes && | ||
Object.entries(leg.alternateRoutes).map( | ||
(route) => route[1].routeShortName |
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.
Route short name is sometimes not specified! This should be an optional
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.
Added a filter to this list to match the one on line 74
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.
This is good but not what I was talking about! route[1]
might not contain routeShortName
which is the issue
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.
Okay, added a fallback to this line
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.
Works, but could possibly be cleaned up a bit more
const alternateRouteNames = | ||
leg.alternateRoutes && | ||
getAlternateRoutesFromLeg(leg) | ||
.map((route) => route[1].routeShortName || undefined) |
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.
This line makes me feel uncomfortable. Without optionals this feels like a disaster waiting to happen... Can we add some optionals here instead of the || undefined
?
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.
That's fair, I was keeping the function consistent, but I agree with you it doesn't make sense to have routes without short names not represented in the list. I added a fallback for the alternate routes but also the default route below.
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.
Great! We should maybe throw a comment in here saying that this could all be cleaned up in the future... Probably when we implement nextLegs
!
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.
LGTM
Description:
Adds the alternative route to the itinerary description in the case that itineraries are merged
PR Checklist: