Repository navigation
Revert arrivalStoptime, departureStoptime and stoptimesForDate behavior changes from #6245 - #6554
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6554 +/- ##
=============================================
+ Coverage 70.24% 70.29% +0.05%
- Complexity 18369 18406 +37
=============================================
Files 2087 2088 +1
Lines 77381 77494 +113
Branches 7839 7868 +29
=============================================
+ Hits 54357 54478 +121
+ Misses 20249 20241 -8
Partials 2775 2775 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
optionsome
left a comment
There was a problem hiding this comment.
Document the two other fields in the schema as well. You could also try adding unit tests for the fromTripTimesWithScheduleFallback method.
…chema.graphqls Co-authored-by: Joel Lappalainen <lappalj8@gmail.com>
… departureStoptimes problems better
| @Test | ||
| void testFromTripTimesWithScheduleFallback() { | ||
| TripPattern tripPattern = service.findPattern(TRIP); | ||
| // Construct a timetable which definitely does not contain this trip, because it is empty. | ||
| Timetable timetable = Timetable.of() | ||
| .withTripPattern(tripPattern) | ||
| .withServiceDate(SERVICE_DATE) | ||
| .build(); | ||
| Instant midnight = ServiceDateUtils.asStartOfService( | ||
| SERVICE_DATE, | ||
| service.getTimeZone() | ||
| ).toInstant(); | ||
| var tripTimeOnDates = TripTimeOnDate.fromTripTimesWithScheduleFallback( | ||
| timetable, | ||
| TRIP, | ||
| SERVICE_DATE, | ||
| midnight, | ||
| service | ||
| ); | ||
| for (var tripTimeOnDate : tripTimeOnDates) { | ||
| assertThat(tripTimeOnDate.getServiceDay()).isNull(); | ||
| assertThat(tripTimeOnDate.getServiceDayMidnight()).isEqualTo(TripTimeOnDate.UNDEFINED); | ||
| } | ||
| } |
There was a problem hiding this comment.
So which case does this test? The one where the trip isn't scheduled to run on the given date or when when it is but without real-time information? Maybe we should test both.
There was a problem hiding this comment.
So which case does this test? The one where the trip isn't scheduled to run on the given date or when when it is but without real-time information? Maybe we should test both.
When the trip isn't scheduled to run. I hoped the comment makes it clear.
I don't like the test setup in this class at all, if I have to continue working on this, I'll start over from an empty file.
There was a problem hiding this comment.
(I also assume that is tested somewhere, I haven't made any changes to that...)
…use a simpler transitservice setup
| public static List<TripTimeOnDate> fromTripTimesWithScheduleFallback( | ||
| Timetable table, | ||
| Trip trip, | ||
| LocalDate serviceDate, | ||
| Instant midnight, | ||
| TransitService transitService | ||
| ) { |
There was a problem hiding this comment.
We could discuss in today's dev meeting if we want to move this method to DefaultTransitService to avoid having TransitService dependency here.
| assertNull(tripTimeOnDate.getServiceDay()); | ||
| assertEquals(tripTimeOnDate.getServiceDayMidnight(), TripTimeOnDate.UNDEFINED); |
There was a problem hiding this comment.
Should we also validate that these triptimes have some "valid" data that can be used for something?
| "datedOrigin": { | ||
| "realtimeDeparture": 0 | ||
| }, | ||
| "datedOrigin": null, | ||
| "timetabledDestination": null, | ||
| "datedDestination": { | ||
| "realtimeArrival": 900 | ||
| }, | ||
| "datedDestination": null, |
There was a problem hiding this comment.
These changes are slightly unexpected. I would have thought this pr only increases the number of cases where data is found?
There was a problem hiding this comment.
This change is certainly unwarranted. I am testing the data should be returned on ADDED_TRIP on the day it does run.
There was a problem hiding this comment.
I have read further, that the pre-6245 logic for departureTime and arrivalTime was wrong.
It first fetched the trip pattern (line 134, without referring to the date), and added the date no matter which date it was. Therefore it didn't process added or replacement trips correctly.
| "datedOrigin": { | ||
| "realtimeDeparture": 0 | ||
| "realtimeDeparture": 41400 | ||
| }, | ||
| "timetabledDestination": { | ||
| "scheduledArrival": 42000 | ||
| }, | ||
| "datedDestination": { | ||
| "realtimeArrival": 900 | ||
| "realtimeArrival": 42000 | ||
| }, |
There was a problem hiding this comment.
This changes also seems a bit random.
There was a problem hiding this comment.
This change is certainly wrong. I am testing the data should be replaced on a REPLACEMENT trip here.
…s used scheduled times
optionsome
left a comment
There was a problem hiding this comment.
I have no idea if the RealTimeTripTimes equals/hashcode have been used somewhere and if this more complicated setup causes some performance issues but I doubt it.
We have a TripTimes Map in InterlineProcessor and a TripTimes Set in OtpTransitServiceBuilder, but that's all. A true result for equals of an object with itself will be approximately equally fast as before, and I just hope that falseness is fast to detect in the majority of cases. hashCode is obviously slower than it used to be, but that shouldn't be too bad, and if it is, we can try to come up with a faster hashCode. Edit: and if InterlineProcessor proves to be an issue, I can immediately see how to rewrite a couple of lines so that it's no longer dependent on that. |
Summary
Partially reverts #6245. Michael will create a more polished version with a new name later. This API will not be changed, even though it is certainly a bug. Too many clients depend on the behavior.
Issue
Fixes #6475
Unit tests
Slightly modified
Documentation
Graphql documentation is changed slightly to make it obvious this is going to be deprecated.
Changelog
From title.
Bumping the serialization version id
No.