-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add previousLegs into GTFS GraphQL API #6142
Merged
optionsome
merged 12 commits into
opentripplanner:dev-2.x
from
Jnction:graphql-previousLegs
Nov 14, 2024
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
124f589
add previousLegs into GTFS GraphQL API
miklcct 364a085
remove duplicate imports from generated files
miklcct 1f0cceb
Merge remote-tracking branch 'upstream/dev-2.x' into graphql-previous…
miklcct ccd001d
Merge branch 'dev-2.x' into graphql-previousLegs
miklcct c715329
use an enum instead of boolean to switch next / previous alternative …
miklcct 22c1f73
rename nextOrPreviousLegs to alternativeLegs
miklcct 30c787b
rename SearchMode to SearchDirection
miklcct c780d5b
Merge branch 'dev-2.x' into graphql-previousLegs
miklcct 0482fb7
move SearchDirection to a separate class and rename to SearchTime
miklcct e129934
move SearchDirection to a separate class and rename to SearchTime
miklcct 64d3978
rename the enum again
miklcct d437d66
rename parameters
miklcct File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
includeDepartBefore
is a slightly difficult to understand boolean name (I know the name is copied over from thegetAlternativeLegs
method) but I think you could give it some more understandable name likepreviousLegsOnly
. In general, we try to avoid boolean method variables that change the behavior. Instead, we prefer to split the methods into two different methods where the name reflects what it does. However, in this case you are just repeating the design decision made in thegetAlternativeLegs
method so it might be ok. We can discuss this in a developer meeting.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.
We discussed this in the developer meeting and came to the conclusion that you should split this private method and also getAlternativeLegs into two methods. One for previous legs and one for next legs.
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.
The
previousLegs
andnextLegs
are doing the same thing, with the only difference in direction. I don't want to duplicate codes so I will switch to an enum instead.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.
Enum isn't really any better than boolean. You can put some of the code that computes the other arguments into methods that can be used by both the nextLegs and previousLegs methods so you can avoid some duplication that way.
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 don't think I can do anything better than converting the boolean to an enum, as the result will be much more complicated.
The single flag is used for multiple purposes:
If I don't use such a flag, I will need two more parameters for
generateLegs
, one to sort the results, one to compare the stop times in the priority queue. I will also need another parameter forgetAlternativeLegs
to sort the legs across different trip patterns as well, so it will be 3 different interrelated new arguments passed down the call stack instead of a single flag, if these arguments become out of sync strange behavior will result.nextLegs
andpreviousLegs
are basically the same thing. They are not different behavior. The same argument can be said of journey planning by departure time or arrival time which should be the same logic, yet I am seeing bugs which happens on arrival only but not departure (#6102).Similarly, there are other flags in
getAlternativeLegs
likeexactOriginStop
,exactDestinationStop
,filter
which can't be split into different methods as well.