-
Notifications
You must be signed in to change notification settings - Fork 56
feat(itinerary): add ability to sort itineraries by fare #1411
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
base: dev
Are you sure you want to change the base?
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.
Looks good! Simple change
@@ -453,10 +454,12 @@ export function addSortingCosts<T extends Itinerary>( | |||
totalFareResult === null ? Number.MAX_VALUE : totalFareResult | |||
|
|||
const rank = calculateItineraryCost(itinerary, config) | |||
const transitFare = getFare(itinerary).transitFare || 0 |
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.
what happens if you just let this stay as undefined
instead setting it to zero? does that mess up the sort?
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.
when the value is zero or undefined
the sort does not change.
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 guess we can remove || 0
as well for cleaner code. I'll let second reviewer decide.
lib/util/itinerary.tsx
Outdated
@@ -48,6 +48,7 @@ export interface ItineraryWithCO2Info extends Itinerary { | |||
export interface ItineraryWithSortingCosts extends Itinerary { | |||
rank: number | |||
totalFare: number | |||
transitFare?: number |
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 noticed this is an optional, which leads me to my next question. I think either you should remove the optional here or remove the || 0
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.
I'll remove the optional, as both values of zero and undefined
do not change the sort order
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.
Maybe if we get an undefined
fare we return .01 or something? So that the confirmed free trips are sorted above fares where we don't actually know.
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.
if a fare is undefined
would that be a data issue? Should we try to handle data issues?
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.
If agencies don't provide us fares we display "no fare available" and i think that's fine to do, I just don't know how it fits into this PR
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.
Blocking because the logic to actually return the fare is commented out.
Wondering also if the user facing label "fare" should be changed to "transit fare"? I'm worried about people assuming we're incorporating rental bike price into the total fare for micromobility trips
There's also a distinction between a $0 fare and "no fare information". I don't think "no fare info" should be weighted the exact same as a free trip? Feels like if you sort by cheapest fare you should see free trips before you see n/a fares. Idk @daniel-heppner-ibigroup what are your thoughts on this |
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'm going to approve so I'm not blocking while on vacation, but would still love to discuss the difference in sorting between undefined fares and $0 fares before we merge!
Adds logic to sort itineraries by only transit fare. The difference between sorting by fare and cost is that itineraries with driving or biking have increased cost than just transit itineraries.
PR Checklist: