Skip to content

Conversation

@t2gran
Copy link
Member

@t2gran t2gran commented Nov 14, 2025

Summary

This PR fixes a bug where extra journeys (GTFS ADDED trips / NeTEx ExtraJourney) were missing from arrival/departure boards. The root cause was that TimetableSnapshot.addPatternToIndex() was incorrectly checking if the stop pattern was modified in real-time, rather than checking if the pattern was created in real-time. This PR introduces a clearer distinction between real-time patterns with modified stop patterns (rerouted trips) and real-time patterns for completely new trips (added trips/extra journeys).

Changes

  • Two boolean flags distinguish different real-time pattern types:
    • realTimeTripPattern: True for any pattern created by real-time updates (rerouted OR added)
    • stopPatternChangedInRealTime: True only when a scheduled trip's stop pattern is modified. This is exactly
      the same as the previous createdByRealtimeUpdater flag.
  • TimetableSnapshot.addPatternToIndex() now uses isRealTimeTripPattern() to include all real-time patterns
  • Builder methods clarify intent:
    • withRealTimeStopPatternChanged(): For rerouted trips with modified stop patterns
    • withRealTimeAddedTrip(): For completely new trips (GTFS ADDED / NeTEx ExtraJourney)
    • : For scheduled trip patterns.

Core changes

  • TripPattern.java: Added dual flags, new methods, improved JavaDoc
  • TripPatternBuilder.java: New builder methods with clear semantics
  • TimetableSnapshot.java: Fixed index update logic (line 600)

Needs more investigation

  • The use of TripPattern#isStopPatternChangedInRealTime() in TransferIndexGenerator and RealTimeRaptorTransitDataUpdater should be investigated. It is probably better to use the more generic isRealTimeTripPattern() in these places, and than add logic for handling ADDED trips (even if that logic is just to ignore these cases). The code as is, is easy to misunderstand.

Build on top of #7130

Issue

Fixes #7008

Testing

  • ✅ Unit tests are updated
  • ✅ Test coverage includes both added trips and rerouted trips

Manual Testing

I have manually tested the case documented in the issue, before and after applying the fix.

Documentation

  • ✅ JavaDoc updated for all modified public methods
  • ✅ Added comprehensive documentation explaining the distinction between realTimeTripPattern and stopPatternChangedInRealTime
  • ✅ Added TODO comments highlighting areas for future improvement

Changelog

  • Should be included in changelog: This fixes a user-visible bug where added trips (GTFS ADDED / NeTEx ExtraJourney) were missing from arrival/departure boards.

Bumping the serialization version id

  • ✅ Needed because of the new flag in TripPattern

@t2gran t2gran added this to the 2.9 (next release) milestone Nov 14, 2025
@t2gran t2gran requested a review from a team as a code owner November 14, 2025 00:30
@t2gran t2gran added !Bug Apply to issues describing a bug and PRs witch fixes it. +Real-Time The issue/PR is related to RealTime updates Entur Test This is currently being tested at Entur labels Nov 14, 2025
@vpaturet vpaturet removed the Entur Test This is currently being tested at Entur label Nov 14, 2025
@habrahamsson-skanetrafiken habrahamsson-skanetrafiken marked this pull request as draft November 20, 2025 13:47
@t2gran t2gran force-pushed the show-extra-journeys-depature-board branch 2 times, most recently from 2bf1a28 to e2f35ad Compare December 8, 2025 14:11
@t2gran t2gran force-pushed the show-extra-journeys-depature-board branch from e2f35ad to 166e934 Compare December 16, 2025 18:40
@t2gran t2gran marked this pull request as ready for review December 16, 2025 18:41
@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 88.46154% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.06%. Comparing base (2891fc2) to head (3509ce3).
⚠️ Report is 418 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...tripplanner/transit/model/network/TripPattern.java 71.42% 1 Missing and 1 partial ⚠️
...nsit/mappers/RealTimeRaptorTransitDataUpdater.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #7052      +/-   ##
=============================================
- Coverage      72.09%   72.06%   -0.03%     
- Complexity     20694    20910     +216     
=============================================
  Files           2244     2282      +38     
  Lines          83899    84466     +567     
  Branches        8347     8434      +87     
=============================================
+ Hits           60488    60873     +385     
- Misses         20482    20623     +141     
- Partials        2929     2970      +41     

☔ 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.

@t2gran t2gran marked this pull request as draft December 17, 2025 00:20
@t2gran t2gran added the Entur Test This is currently being tested at Entur label Dec 17, 2025
@vpaturet vpaturet added +Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR and removed Entur Test This is currently being tested at Entur labels Dec 17, 2025
@leonardehrenfried
Copy link
Member

You have to resolve the conflicts, I'm afraid.

@t2gran t2gran added the Entur Test This is currently being tested at Entur label Dec 19, 2025
Comment on lines 146 to 148
if (stopPatternChangedInRealTime && !realTimeTripPattern) {
throw new IllegalStateException();
}

Choose a reason for hiding this comment

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

I think guard statements should go at the top or next to where we set the parameters. Otherwise it is easy to miss it when reading the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, but for constructors we often do validation it at the end, or where the assignment happens. Doing it at the end has the power that you can do it on the members - not the arguments. So, if there is logic in the constructor you validate the result. In short, syntactic validation (preconditions) of input fields should be done first (or part of assignment this.a = requireNonNull(a)), semantic validation last(postconditions). This constructor follow this.

.withNetexSubmode(trip.getNetexSubMode())
.withStopPattern(stopPattern)
.withCreatedByRealtimeUpdater(true)
.withRealTimeStopPatternChanged()
Copy link
Contributor

@vpaturet vpaturet Jan 12, 2026

Choose a reason for hiding this comment

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

Should it be withRealTimeStopPatternChanged() in the case of a modified trip and withRealTimeAddedTrip() in the case of an added trip?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not changed, it might be wrong - but in that case it should be fixed in a separate PR. The old code:

tripPattern = TripPattern.of(id)
        :
        .withCreatedByRealtimeUpdater(true)

The withCreatedByRealtimeUpdater(true) was set for all TripPatterns where the stop-pattern was modified. But, NOT if the pattern was new.

@t2gran t2gran force-pushed the show-extra-journeys-depature-board branch from 270cf7a to 3509ce3 Compare January 14, 2026 10:48
@t2gran t2gran added this pull request to the merge queue Jan 20, 2026
Merged via the queue into opentripplanner:dev-2.x with commit 03cc733 Jan 20, 2026
8 checks passed
@t2gran t2gran deleted the show-extra-journeys-depature-board branch January 20, 2026 12:06
t2gran pushed a commit that referenced this pull request Jan 20, 2026
t2gran pushed a commit that referenced this pull request Jan 20, 2026
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. +Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR Entur Test This is currently being tested at Entur +Real-Time The issue/PR is related to RealTime updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trips added in realtime-data (SIRI ET ExtraJourneys) do not appear in departure-/arrival boards

4 participants