Skip to content

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

Merged
merged 5 commits into from
Mar 28, 2025

Conversation

amy-corson-ibigroup
Copy link
Contributor

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:

  • Does the code follow accessibility standards (WCAG 2.1 AA Compliant)?
  • Are all languages supported (Internationalization/Localization)?
  • Are appropriate Typescript types implemented?

@amy-corson-ibigroup amy-corson-ibigroup changed the title StrictValidCombos configuration acceptableValidModeCombos configuration Mar 17, 2025
Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a 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.

Comment on lines 1130 to 1131
modeCombo.every((m) => vc.includes(m)) &&
vc.every((m) => modeCombo.includes(m))
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you!

Copy link
Contributor Author

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!

Copy link
Contributor

@daniel-heppner-ibigroup daniel-heppner-ibigroup left a 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))
Copy link
Contributor

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!

['WALK', 'TRANSIT', 'PERSONAL'],
['WALK', 'TRANSIT', 'CAR'],
['CAR']
]
Copy link
Contributor

Choose a reason for hiding this comment

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

indentation

@amy-corson-ibigroup amy-corson-ibigroup merged commit 519b06d into dev Mar 28, 2025
9 checks passed
@amy-corson-ibigroup amy-corson-ibigroup deleted the strict-valid-mode-combos branch March 28, 2025 17:30
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.

4 participants