-
Notifications
You must be signed in to change notification settings - Fork 59
Add Accessibility Labels to Legs and Itineraries #456
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
Changes from all commits
a8520ee
83e10d7
723e386
a4d4cb0
bc19c7b
1aefcd0
4227c50
a6d3d35
9ea4c9a
e0c14fd
6e7678d
aed0058
26049a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /** | ||
| * Determine if an itinerary has accessibility scores | ||
| */ | ||
| export const itineraryHasAccessibilityScores = (itinerary) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the i18n work, I was organising util functions into
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, if the function is used from multiple files then it should go to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I was merging too many things this morning and accidentally forgot about this! Very sorry. The fix is in #487 |
||
| return !!itinerary.legs.find(leg => !!leg.accessibilityScore) | ||
| } | ||
|
|
||
| /** | ||
| * Calculates the total itinerary score based on leg score by weighting | ||
| * each leg equally | ||
| */ | ||
| export const getAccessibilityScoreForItinerary = (itinerary) => { | ||
| const scores = itinerary.legs | ||
| .map((leg) => leg.accessibilityScore || null) | ||
| .filter((score) => score !== null) | ||
|
|
||
| return scores.reduce((prev, cur) => prev + (cur * (1 / scores.length)), 0) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.