-
Notifications
You must be signed in to change notification settings - Fork 1.1k
return stoptimesForDate from the schedule if it is called with no parameter on a day when the trip does not run #6480
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
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6480 +/- ##
=============================================
- Coverage 70.20% 70.18% -0.03%
- Complexity 18313 18317 +4
=============================================
Files 2080 2082 +2
Lines 77182 77220 +38
Branches 7831 7833 +2
=============================================
+ Hits 54183 54193 +10
- Misses 20230 20259 +29
+ Partials 2769 2768 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…es even if the trip does not run today. Technically wrong, but UIs rely on this, and have for a long time
…explicit parameter of today
…the corresponding case with useScheduledWhenNonRunning
public Optional<List<TripTimeOnDate>> getTripTimeOnDates( | ||
Trip trip, | ||
LocalDate serviceDate, | ||
boolean useScheduledWhenNonRunning |
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 name of this parameter is a bit confusing as my first intuition at least is that it would use scheduled times from the given date instead of trying to use real-time when trip is cancelled, or something like that. Maybe something like fallbackToNextScheduledDate
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.
I think we usually use the word "schedule" for the describing the "planned data". We had this discussion last year at some point but I can't quite remember what we decided. However, in this case I think "scheduled date" doesn't indicate as strongly that we would be using planned data so I think we could improve the name. Problem with fallbackToBaseTimetable
is that it doesn't tell that the returned times could actually be from another service date.
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.
fallbackToBaseTimetableOnRunningDate
?
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 know Joel will say that doesn't indicate which date, but the fact is that it does not matter which date it is, because it's not really any date. It's just the base case, unchanged by realtime data. The returned result will not include dates, if you try to fetch one it will be null.
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 think we use "running date" sometimes to call the actual date that the trip is servicing on. So for example, if a trip lasts 3 days, it's running on 3+ running dates. So this could be slightly confusing as it could confuse people into thinking that the serviceDate parameter could be used as a running date if there is no service on the service date. Maybe fallbackToNextPlannedTimetable
? I think the words we use for the planned data are either scheduled or planned.
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.
fallbackToPlannedTimetableOnNonRunningDate
?
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.
As said, I think we should avoid using the word running date here because it can mean slightly different thing. Also, I first thought you mean timetable on non running date, but I guess you mean you fall back to planned timetable when there is no service on the service date? I know that the "next" I used in my suggestion is not really that relevant, it could be any date that the trip is servicing on, but I wanted to somehow tell that the timetables don't necessarily come from the given service date.
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.
Yes, we want to specify that "we fall back to the planned timetable when the service does not run on the given service date".
How about fallbackToPlannedTimetableOnNoServiceDate
?
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.
That's ok for me.
* @return if the trip doesn't run on the date specified, return schedule if | ||
* useScheduledWhenNonRunning is true, empty otherwise. Logically this is confusing, | ||
* but existing UIs depend on this. |
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.
* @return if the trip doesn't run on the date specified, return schedule if | |
* useScheduledWhenNonRunning is true, empty otherwise. Logically this is confusing, | |
* but existing UIs depend on this. | |
* @return if the trip doesn't run on the specified service date, return trip times from | |
* the next scheduled service date if fallbackToNextScheduledDate is true, empty | |
* otherwise. Logically this is confusing, but existing API users depend on this. |
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 think the description above is not accurate as well. There is a possibility that the next scheduled service date has been modified by the real-time updates. For example, today is 2025-03-06 when the trip does not run, and the service on 2025-03-07 has been replaced. This method won't return the replaced service, but instead the original scheduled times without real-time updates.
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.
Yep, I think we could add a sentence describing that real-time data is only used for the current date.
application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls
Outdated
Show resolved
Hide resolved
application/src/test/java/org/opentripplanner/transit/service/DefaultTransitServiceTest.java
Outdated
Show resolved
Hide resolved
…TransitService.java Co-authored-by: Joel Lappalainen <[email protected]>
…chema.graphqls Co-authored-by: Joel Lappalainen <[email protected]>
…DefaultTransitServiceTest.java Co-authored-by: Joel Lappalainen <[email protected]>
* @return if the trip doesn't run on the date specified, return schedule if | ||
* useScheduledWhenNonRunning is true, empty otherwise. Logically this is confusing, | ||
* but existing UIs depend on this. |
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 think the description above is not accurate as well. There is a possibility that the next scheduled service date has been modified by the real-time updates. For example, today is 2025-03-06 when the trip does not run, and the service on 2025-03-07 has been replaced. This method won't return the replaced service, but instead the original scheduled times without real-time updates.
new TripTimeOnDate(REALTIME_TRIP_TIMES, 1, REAL_TIME_PATTERN, SERVICE_DATE, midnight) | ||
) | ||
), | ||
service.getTripTimeOnDates(TRIP, SERVICE_DATE, true) |
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 think you are testing for a wrong date. SERVICE_DATE
is a date the service does run, and NO_SERVICE_DATE
is a date the service does not run.
application/src/main/java/org/opentripplanner/transit/service/TransitService.java
Outdated
Show resolved
Hide resolved
application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls
Outdated
Show resolved
Hide resolved
My only concern left is the name of the boolean parameter. I have merged this PR into our test deployment which will be deployed over the weekend, and I will check if it works early next week (especially regarding to added trips). |
…TransitService.java Co-authored-by: Michael Tsang <[email protected]>
…chema.graphqls Co-authored-by: Michael Tsang <[email protected]>
public Optional<List<TripTimeOnDate>> getTripTimeOnDates( | ||
Trip trip, | ||
LocalDate serviceDate, | ||
boolean fallbackToPlannedTimetableOnNonRunningDate |
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 latest suggestion for the name is fallbackToPlannedTimetableOnNoServiceDate
.
Optional<List<TripTimeOnDate>> getTripTimeOnDates( | ||
Trip trip, | ||
LocalDate serviceDate, | ||
boolean fallbackToPlannedTimetableOnNonRunningDate |
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.
fallbackToPlannedTimetableOnNoServiceDate
/** | ||
* @return if the trip doesn't run on the specified service date, return scheduled trip times, | ||
* unmodified by any realtime data, if | ||
* fallbackToNextScheduledDate is true, empty otherwise. Logically this is confusing, but | ||
* existing API users depend on this. | ||
*/ |
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.
/** | |
* @return if the trip doesn't run on the specified service date, return scheduled trip times, | |
* unmodified by any realtime data, if | |
* fallbackToNextScheduledDate is true, empty otherwise. Logically this is confusing, but | |
* existing API users depend on this. | |
*/ | |
/** | |
* @return if the trip doesn't run on the specified service date, return scheduled trip times, | |
* unmodified by any realtime data, if fallbackToPlannedTimetableOnNoServiceDate is true, | |
* empty otherwise. Logically this is confusing, but existing API users depend on this. | |
*/ |
application/src/test/java/org/opentripplanner/transit/service/DefaultTransitServiceTest.java
Outdated
Show resolved
Hide resolved
@miklcct in #6245 you did some changes to trip's I have thought a bit more about how people might have used the |
I am using stoptimesForDate field to fetch real-time stop times for yesterday, today and tomorrow as a workaround for the inability to query the times for the whole trip from a stoptimes, so I have to match the service dates and pick the correct one, and I plan to use this same field in another page where the user can query the timetable for the same trip on an arbitrary date as well. For arrivalStopTime and departureStopTime, if the date is not specified, the scheduled time is used so there are no functional changes for these two fields, and stoptimes do not accept a date parameter so no functional change is done on that, and it always return the scheduled times. In the long run I plan to deprecate the whole class of Btw, what is the issue caused on Digitransit by my change? Can you please explain how Digitransit uses the information from |
Btw I think that there is also a possible bug in the digitransit-ui after I do a Github search on the use of This bug should happen if you get an itinerary which involves taking service across two service days (such as an overnight trip), or plan a future itinerary, in this case you will be fetching the stoptimes for today even though that the itinerary is for tomorrow, so at worst the complete wrong times will be shown and mislead the user, in case the trip today is heavily delayed (where the user will think that the trip tomorrow is delayed) or even replaced completely with a REPLACEMENT trip. May I kindly suggest that everyone affected by this change check your intention of your GraphQL queries that you are showing the stop times of the correct date to the user, thanks, or if you ALWAYS intend to show the scheduled times (not even today's delays) if |
The first problem we spotted was when you did a itinerary search for the future and opened some itinerary suggestion because it was using stoptimesForDate without serviceDate parameter.
Yep, we plan to go through our usage of the stoptimesForDate field to see if it is used properly. However, the problem is that there hundreds of API users and it's difficult to have them all change their software to match the new implementation. Therefore, I think we will look into added new fields to the trip to replace the old stoptimes fields. Perhaps we can discuss this a bit tomorrow either in the normal dev meeting or in the design meeting? |
In such case, it is highly likely that you are showing the wrong delays if the same trip on today is delayed. Try to plan a journey for the future on a route which has a severe delay today.
I can discuss this in a design meeting as I have intention to deprecate serviceDay field in |
After the developer meeting, we have discussed that we will revert to the old behavior (return the planned schedule regardless if the service actually run) since we are not supposed to introduce breaking changes into the API, and leave a documentation for this strange behavior and a workaround for the intended behavior using In the long term, we will deprecate this field, and all date-dependent fields in Trip, and move all such similar usages to TripOnServiceDate instead. P.S. unfortunately the change has already been released in the 2.7 version into the wild, possibly we need to gather feedback from API users as well if they actually depend on the old behavior, or if this change has uncovered long-standing bugs when planning journeys tomorrow. |
Also, please don't remove my test. Change it to test the behavior that we have agreed and document it. |
I'm assigned the reviewer for this PR. Is there anything for me to do or will it be dropped? |
Let's discuss if we want to revert to the pre-2.7 non-intuitive behaviour, or if my change actually resulted in hard-to-find bugs discovered in the consumers where they should fix instead. Unfortunately the damage has been done and people will rightly complain in either case. |
Discarded, we will instead just revert the offending PR. |
Fixes Issue #6475
Technically the solution here is wrong, but longstanding UIs (like digitransit-ui) rely on getting the scheduled timetable when running stoptimesForDate without a parameter on a wrong day.