Skip to content

Pass through per-trip route_id, headsign, start_date, start_time instead of gating on active trip#466

Open
KTibow wants to merge 2 commits into
OneBusAway:mainfrom
KTibow:fix/per-trip-metadata
Open

Pass through per-trip route_id, headsign, start_date, start_time instead of gating on active trip#466
KTibow wants to merge 2 commits into
OneBusAway:mainfrom
KTibow:fix/per-trip-metadata

Conversation

@KTibow

@KTibow KTibow commented Jul 3, 2026

Copy link
Copy Markdown

route_id, headsign, start_date, start_time, and schedule_relationship were only set for the active trip. We already fetch TripDetailsBean containing this data for every trip — we just never use it. This change uses the per-trip data for all trips on the block.

The old comment "we only know route if we are on activeTrip, the block may interline!" was incorrect — each trip has its own route in the static GTFS schedule, and getTripDetailsForTrip() returns it.

Disclosure: Generated by DeepSeek V4 Pro with CI verification

Summary by CodeRabbit

  • New Features
    • Enhanced real-time trip updates to include richer per-trip information such as route, start date/time, headsign, and schedule relationship when available.
  • Bug Fixes
    • Improved accuracy of trip metadata by deriving fields from per-trip details instead of shared schedule data.
    • Refined delay handling so delay is applied to the matching active trip while other trip details are populated more correctly.

…ead of gating on active trip

route_id, headsign, start_date, start_time, and schedule_relationship
were only set for the active trip. getScheduleForTrip() already fetched
TripDetailsBean containing this data for every trip — it was just never
used. This change uses the per-trip data for all trips on the block.

The old comment 'we only know route if we are on activeTrip, the block
may interline!' was incorrect — each trip has its own route in the
static GTFS schedule, and getTripDetailsForTrip() returns it.
@CLAassistant

CLAassistant commented Jul 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

TripUpdatesForAgencyAction’s timepoint-driven update flow now fetches full trip details per trip, uses those details to populate TripDescriptor fields, and derives the stop-time schedule from the returned trip details while keeping delay assignment limited to the active trip.

Changes

Trip Updates Timepoint Detail Fetch

Layer / File(s) Summary
Trip details helper replacement
onebusaway-api-webapp/src/main/java/org/onebusaway/api/actions/api/gtfs_realtime/TripUpdatesForAgencyAction.java
Replaces getScheduleForTrip with getTripDetailsForTrip, returning TripDetailsBean instead of TripStopTimesBean and wiring the same query fields into _service.getSingleTripDetails(query).
Timepoints flow uses trip details
onebusaway-api-webapp/src/main/java/org/onebusaway/api/actions/api/gtfs_realtime/TripUpdatesForAgencyAction.java
serveTripUpdatesFromTimepoints derives schedule from tripDetails.getSchedule(), populates route/start date/start time/scheduleRelationship/headsign from per-trip details, and applies delay only to the active trip.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: passing per-trip trip metadata instead of limiting it to the active trip.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@KTibow

KTibow commented Jul 3, 2026

Copy link
Copy Markdown
Author

Once again, not signing the CLA because it needs to be updated to use a custom gist instead of the SAP default

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@onebusaway-api-webapp/src/main/java/org/onebusaway/api/actions/api/gtfs_realtime/TripUpdatesForAgencyAction.java`:
- Around line 179-183: The start_date and start_time values in
TripUpdatesForAgencyAction are still derived from tripStatus.getServiceDate(),
which can cause downstream trips to inherit the active trip’s service day.
Update the TripUpdatesForAgencyAction logic around tripDesc.setStartDate,
tripDesc.setStartTime, and the tripDetails.getStatus() check to use the per-trip
service date/status when available, and skip setting a synthetic midnight
start_time when per-trip status is missing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e42e41fc-ee72-469f-9405-90d2e92a973a

📥 Commits

Reviewing files that changed from the base of the PR and between 9bd105b and e11d2e3.

📒 Files selected for processing (1)
  • onebusaway-api-webapp/src/main/java/org/onebusaway/api/actions/api/gtfs_realtime/TripUpdatesForAgencyAction.java

… is null

The start_date and start_time fields were still derived from
tripStatus.getServiceDate() (the active trip's service date).
This caused downstream trips on the same block to inherit the
active trip's service date, which was incorrect.

Now using tripDetails.getServiceDate() for per-trip accuracy.
Also skips setting a synthetic midnight start_time when
tripDetails.getStatus() is null, instead of emitting a
potentially misleading value.
@KTibow KTibow changed the title Pass through per-trip route_id, headsign, start_date, start_time intead of gating on active trip Pass through per-trip route_id, headsign, start_date, start_time instead of gating on active trip Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants