-
Notifications
You must be signed in to change notification settings - Fork 54
acceptableValidModeCombos configuration #1366
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.
Approving with a few nits.
lib/actions/apiV2.js
Outdated
modeCombo.every((m) => vc.includes(m)) && | ||
vc.every((m) => modeCombo.includes(m)) |
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.
You can avoid one of the every
by checking that the sizes of arrays are the same before hand.
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.
Thank you!
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.
Since I took this logic from core-utils
, I used opentripplanner/otp-ui#819 as an opportunity to apply this feedback there too!
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
return validModeCombinations.find( | ||
(vc) => | ||
modeCombo.length === vc.length && | ||
vc.every((m) => modeCombo.includes(m)) |
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 wasn't sure but indeed this is the most efficient way to do this!
example-config.yml
Outdated
['WALK', 'TRANSIT', 'PERSONAL'], | ||
['WALK', 'TRANSIT', 'CAR'], | ||
['CAR'] | ||
] |
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.
indentation
Description:
Creates a configurable list of acceptable mode combinations and filters itineraries to only return ones with mode combos that adhere to this list.
This should filter out itineraries with unwanted combinations such as "WALK" + "DRIVE"
PR Checklist: