Skip to content

fix: include parent station routes and agencies in stop references #1107

Open
ARCoder181105 wants to merge 2 commits into
OneBusAway:mainfrom
ARCoder181105:fix-1095
Open

fix: include parent station routes and agencies in stop references #1107
ARCoder181105 wants to merge 2 commits into
OneBusAway:mainfrom
ARCoder181105:fix-1095

Conversation

@ARCoder181105

@ARCoder181105 ARCoder181105 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Resolves #1095 by ensuring that when a requested stop is linked to a parent_station, the parent station's routes and owning agencies are properly included in the API response's references block.

Changes Made

  • Reference Assembly (stop_handler.go): Updated the handler so that when parent station routes are retrieved, their full route objects and owning transit agencies are appended to references.Routes and references.Agencies (satisfying the OneBusAway spec contract).
  • Deduplication: Added uniqueRouteIDs tracking to prevent duplicate route entries in references.Routes when a route serves both the child stop and its parent station.
  • Test Coverage (stop_handler_test.go): Updated TestStopHandler_ParentStation with a route assigned exclusively to a parent station to assert that it correctly appears in references.routes and references.agencies.

Testing

  • Live verified API response against Sound Transit rail dataset (40_1108.json).
  • Ran make test to confirm all test suites pass without regression.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed duplicate route references in stop details when a stop and its parent station share routes.
    • Parent stations now correctly include their own unique routes and agencies in reference data.
    • Route and agency lists shown for stops are now more consistent and free of repeated entries.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ARCoder181105, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 7 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 37152552-e715-427a-aabb-2dcc8200a8c9

📥 Commits

Reviewing files that changed from the base of the PR and between 296f819 and 1c3a176.

📒 Files selected for processing (1)
  • internal/restapi/stop_handler_test.go
📝 Walkthrough

Walkthrough

The stop handler now deduplicates route references across stop and parent-stop lookups before deriving agency references. The parent-station test seeds a parent-only route/trip and verifies the parent route and agency appear in the references block.

Changes

Stop reference population

Layer / File(s) Summary
Route and agency deduplication
internal/restapi/stop_handler.go
Route references are collected with combined route IDs, duplicates are skipped across stop and parent-stop routes, and agency references are built from the deduplicated agency ID set.
Parent-station reference coverage
internal/restapi/stop_handler_test.go
The parent-station test adds a parent-only route/trip fixture, updates comments, and asserts the parent route and agency are present in references.Routes and references.Agencies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • OneBusAway/maglev#1049: Updates the same stop reference-population path in internal/restapi/stop_handler.go, including ShouldIncludeReferences gating around route and agency fetching.

Suggested reviewers

  • burma-shave
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: adding parent station routes and agencies to stop references.
Linked Issues check ✅ Passed The changes match #1095 by appending parent routes and agencies to references and updating the test with a parent-only route.
Out of Scope Changes check ✅ Passed The deduplication logic is directly tied to the stated fix and does not introduce unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@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 `@internal/restapi/stop_handler_test.go`:
- Around line 357-376: The current test only checks parent-only references and
does not cover the deduplication path in uniqueRouteIDs. Update the stop handler
test to seed the same route on both the child and parent stop fixtures, then
assert in model.Data.References.Routes that this shared route appears exactly
once. Use the existing stop handler test setup and route reference assertions as
the location to add the new fixture and count-based deduplication check.
🪄 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: 6189dd2b-59cb-4a3b-9269-e9e7dc3a0b6d

📥 Commits

Reviewing files that changed from the base of the PR and between c298c6e and 296f819.

📒 Files selected for processing (2)
  • internal/restapi/stop_handler.go
  • internal/restapi/stop_handler_test.go

Comment thread internal/restapi/stop_handler_test.go
@sonarqubecloud

Copy link
Copy Markdown

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.

stop: Missing references for Parent Station routes and agencies

1 participant