fix: honor includeReferences parameter#1111
Conversation
Gate the population of the references block behind the ShouldIncludeReferences helper. This correctly omits agencies, routes, trips, stops, and situations when includeReferences=false, reducing payload size and saving database alert queries. Added unit tests to verify behavior for false, true, and absent states.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe vehicles-for-agency handler now conditionally populates ChangesVehicles-for-agency reference gating
Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|



Summary
Fixes a spec gap where the
vehicles-for-agencyendpoint ignored theincludeReferencesparameter and always populated the references block.Problem
The spec states that passing
includeReferences=falseshould omit the references block to reduce payload size. The handler was unconditionally building and returning all references (agencies, routes, trips, situations), wasting both bandwidth and server resources.Changes
ShouldIncludeReferences(r)helper.false, the response now correctly returns empty arrays for the references block usingmodels.NewEmptyReferences().includeReferences=false(asserting empty references) andtrue/absent (asserting populated references using table-driven tests).Closes #1104
Summary by CodeRabbit
includeReferencesoption, returning reference data only when requested.