Skip to content

Revert arrivalStoptime, departureStoptime and stoptimesForDate behavior changes from #6245 - #6554

Merged
tkalvas merged 12 commits into
opentripplanner:dev-2.xfrom
HSLdevcom:partial-revert-pr6245
Mar 28, 2025
Merged

tkalvas merged 12 commits into
opentripplanner:dev-2.xfrom
HSLdevcom:partial-revert-pr6245

Conversation

@tkalvas

@tkalvas tkalvas commented Mar 19, 2025 •

Copy link
Copy Markdown
Contributor

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.

@tkalvas
tkalvas requested a review from a team as a code owner March 19, 2025 08:58
@codecov

codecov Bot commented Mar 19, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.26531% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.29%. Comparing base (52dc65f) to head (306d0cc).
⚠️ Report is 1904 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...entripplanner/apis/gtfs/datafetchers/TripImpl.java 75.00% 9 Missing and 4 partials ⚠️
...er/transit/model/timetable/ScheduledTripTimes.java 38.09% 12 Missing and 1 partial ⚠️
...ner/transit/model/timetable/RealTimeTripTimes.java 37.50% 10 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@miklcct

miklcct commented Mar 20, 2025 •

Copy link
Copy Markdown
Contributor

Can you make sure that the NPEs in #6088 and #6242 won't be reintroduced? Otherwise it's good for me.

@optionsome optionsome changed the title revert arrivalStoptime, departureStoptime and stoptimesForDate from pr6245 Revert arrivalStoptime, departureStoptime and stoptimesForDate from #6245 Mar 20, 2025
@tkalvas

tkalvas commented Mar 21, 2025

Copy link
Copy Markdown
Contributor Author

Can you make sure that the NPEs in #6088 and #6242 won't be reintroduced? Otherwise it's good for me.

Great issues, thanks for digging them from the history. I will fix them.

@tkalvas
tkalvas marked this pull request as draft March 21, 2025 08:49
@tkalvas
tkalvas marked this pull request as ready for review March 24, 2025 07:31
@optionsome optionsome changed the title Revert arrivalStoptime, departureStoptime and stoptimesForDate from #6245 Revert arrivalStoptime, departureStoptime and stoptimesForDate behaviour changes from #6245 Mar 24, 2025
@optionsome optionsome changed the title Revert arrivalStoptime, departureStoptime and stoptimesForDate behaviour changes from #6245 Revert arrivalStoptime, departureStoptime and stoptimesForDate behavior changes from #6245 Mar 24, 2025

@optionsome optionsome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document the two other fields in the schema as well. You could also try adding unit tests for the fromTripTimesWithScheduleFallback method.

@optionsome optionsome added the Digitransit Test Feature is under testing in Digitransit environment(s) label Mar 24, 2025
tkalvas and others added 2 commits March 24, 2025 16:36
…chema.graphqls

Co-authored-by: Joel Lappalainen <lappalj8@gmail.com>
@tkalvas
tkalvas requested a review from optionsome March 25, 2025 09:19
@tkalvas
tkalvas marked this pull request as draft March 25, 2025 13:16
@tkalvas
tkalvas marked this pull request as ready for review March 25, 2025 13:45
Comment on lines +279 to +302
@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);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I also assume that is tested somewhere, I haven't made any changes to that...)

Comment on lines +93 to +99
public static List<TripTimeOnDate> fromTripTimesWithScheduleFallback(
Timetable table,
Trip trip,
LocalDate serviceDate,
Instant midnight,
TransitService transitService
) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could discuss in today's dev meeting if we want to move this method to DefaultTransitService to avoid having TransitService dependency here.

@tkalvas
tkalvas requested a review from optionsome March 27, 2025 14:33
Comment on lines +95 to +96
assertNull(tripTimeOnDate.getServiceDay());
assertEquals(tripTimeOnDate.getServiceDayMidnight(), TripTimeOnDate.UNDEFINED);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also validate that these triptimes have some "valid" data that can be used for something?

Comment on lines +6 to +8
"datedOrigin": {
"realtimeDeparture": 0
},
"datedOrigin": null,
"timetabledDestination": null,
"datedDestination": {
"realtimeArrival": 900
},
"datedDestination": null,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are slightly unexpected. I would have thought this pr only increases the number of cases where data is found?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is certainly unwarranted. I am testing the data should be returned on ADDED_TRIP on the day it does run.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 46 to 54
"datedOrigin": {
"realtimeDeparture": 0
"realtimeDeparture": 41400
},
"timetabledDestination": {
"scheduledArrival": 42000
},
"datedDestination": {
"realtimeArrival": 900
"realtimeArrival": 42000
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes also seems a bit random.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is certainly wrong. I am testing the data should be replaced on a REPLACEMENT trip here.

@tkalvas
tkalvas requested review from miklcct and optionsome March 28, 2025 10:33

@optionsome optionsome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tkalvas
tkalvas merged commit cc631ac into opentripplanner:dev-2.x Mar 28, 2025
@tkalvas
tkalvas deleted the partial-revert-pr6245 branch March 28, 2025 14:48
t2gran pushed a commit that referenced this pull request Mar 28, 2025
@tkalvas

tkalvas commented Mar 28, 2025 •

Copy link
Copy Markdown
Contributor Author

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.

@t2gran t2gran added this to the 2.8 (next release) milestone Aug 26, 2025
@t2gran t2gran added !Bug Apply to issues describing a bug and PRs witch fixes it. and removed Regression labels Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!Bug Apply to issues describing a bug and PRs witch fixes it. Digitransit Test Feature is under testing in Digitransit environment(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

trip.stoptimesForDate in the GTFS GraphQL API doesn't work without serviceDate for trips that don't happen today

5 participants