-
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 query for cancelled trips to GTFS GraphQL API #5393
Add query for cancelled trips to GTFS GraphQL API #5393
Conversation
It is much more efficient to filter trips in early stage
src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls
Outdated
Show resolved
Hide resolved
src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java
Outdated
Show resolved
Hide resolved
My current understanding of what should be done:
While doing this, we should not add features which are not needed yet, or unnecessarily duplicated fields of the Trip. In my opinion, duplicating a field from the Trip object to DatedTrip level indicates that the values presumably differ. |
Yes, I would keep the implementation of @optionsome however thinks that you should include stop times. I can live without them and can add them when I need it. |
@vesameskanen can you be the second reviewer? |
application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls
Outdated
Show resolved
Hide resolved
There has been a long discussion about the API schema above. I just want to summarise my input for future reference. I quickly put together an "API domain model" for this. The diagram below is my suggestion to the design, it follows the guideline in this PR. In the future I want us to draw diagrams like the on below - they are much easier to read and discuss. If we draw at a API level or OTP domain level probably does not matter - but try to focus on the entities, value-objects and the relationships. When we agree on the "language", then it become a technical task to map it to a GraphQL schema or Java model.
|
@optionsome You have conflicts again. |
I think people can confuse the concept of a normal date vs service date.
The thing is, if we don't make the TripOnDate a union in the schema, "There might be more stop-locations than in the scheduled plan" issue (or similar issues) might be difficult to solve. Making the calls a union/interface could lessen these types of issues but I don't know if even that is a solution for the aforementioned issue.
I think we decided to call it CallTime.
I didn't make them required because I'm not sure if we always will have arrival time for the first stop or departure time for the last stop in the future.
In general, I think designing the domain is a good idea, however I think designing the schema is even more important since changing that is much more difficult.
I wasn't quite sure what is the best model for this. Should the scheduled/estimates be grouped together inside departure or arrival fields or should there be schedules and estimates which have departure and arrival fields. For the non-flex trips, grouping the estimates and schedules together feels more natural. However, with flex time windows it's not possible because there is no scheduled arrival or departure. That was the reason why I ended up using a union for the Calls so these could be modeled in different fashion. |
We did some schema design with @t2gran, I'll update this pr to match the design later: { calls { stopLocation = (Stop | StopArea | GroupOfStops) : CallStopLocation Union scheduled { plannedStatus = SKIPPED/SCHEDULED time { (TimeWindow | ArrivalDepartureTime) : CallScheduledTime timeWindow { start OffsetDateTime end OffsetDateTime } or { arrival OffsetDateTime departure OffsetDateTime } } } realTime CallRealTime { cancelled = SKIPPED/SCHEDULED arrival EstimatedTime { time delay uncertainty percentage recorded RECORDED/ESTIMATE/UNKNOWN } departure { time delay isActualTime = false } } } } |
I've implemented new version of schema now. I'm not quite sure where some of the model classes needed by the API should be. They are now in the GTFS API package and elsewhere which is probably not ideal at least. |
The schema design we did with @t2gran includes some things that I have not implemented in the scope of this pr as they are not needed for this. |
} | ||
|
||
"What is scheduled for a trip on a service date for a stop location." | ||
type CallSchedule { |
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 is the reason for wrapping this in another type?
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 can later include information if there is a planned cancellation, for example.
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 looked this for a while and cannot find any problems with it other than the question about the wrapped type.
I must admit, I have been reviewing this so many times, that I'm having trouble concentrating.
"Scheduled arrival and departure times for this stop location." | ||
schedule: CallSchedule | ||
"The stop where this arrival/departure happens." | ||
stopLocation: CallStopLocation! |
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 is the naming convention you decided on, naming the union by the "aggregate" Call
or the wrapping type StopCall
. In this case CallStopLocation
or StopCallStopLocation
.
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 not sure if we have made a clear decision on this. It depends a bit on if we think there will be some other need for stop locations within the call scope or not. I think mostly we would have the same set of different types of stop locations for different use cases.
Just, so we are on the same page - the domain model is the conceptual model of the "real world" - if you do a mistake here, the schema will be wrong, and the code will be wrong - it it those mistakes that cost 1000 times more than other mistakes. |
That is true but we can also make wrong schema decisions based on a valid domain model so we should have some focus on the schema design as well. |
✅ For the record I approve the |
Summary
This PR adds a query, which returns information about cancelled trips, into Gtfs graphQL API. The query supports paging and filtering by feed id. It returns a list of (trip, date) pairs.
Unit tests
None. The new code has been tested manually using graphiQL endpoint. Changing trip selector in DefaultTransitService class temporarily to return UPDATED (not CANCELED) trips helps to collect test trips with any realtime modified data.
Documentation
Docs in the graphQL schema