Omit zero update times for vehicles for agency#1116
Conversation
Per the vehicles-for-agency spec, lastUpdateTime and lastLocationUpdateTime must be absent when no real-time data is available. Previously, the handler forced these to the current server time or emitted them as 0. This commit does the following: - Removes fallback clock times in the handler. - Adds omitzero to the exclusive VehicleStatus fields. - Uses a scoped custom MarshalJSON wrapper to omit zero times from the shared TripStatus exclusively for this endpoint. This scoped approach guarantees zero impact on other endpoints (like trips-for-route) that explicitly require a 0 value.
|
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 (5)
📝 WalkthroughWalkthroughAdds a ChangesVehicles-for-agency timestamp omission
Sequence Diagram(s)sequenceDiagram
participant Client
participant VehiclesForAgencyHandler
participant vehicleStatusResponse
participant JSONEncoder
Client->>VehiclesForAgencyHandler: GET /vehicles-for-agency
VehiclesForAgencyHandler->>VehiclesForAgencyHandler: build VehicleStatus (skip currentTime default)
VehiclesForAgencyHandler->>vehicleStatusResponse: wrapVehicleStatusesForResponse
vehicleStatusResponse->>JSONEncoder: MarshalJSON
JSONEncoder->>JSONEncoder: delete zero tripStatus time fields
JSONEncoder-->>Client: response without zero timestamps
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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
This PR aligns the
vehicles-for-agencyendpoint with its spec by omittinglastUpdateTimeandlastLocationUpdateTimewhen no real-time update has been received, rather than emitting a0or a fabricated server time.Changes
api.Clock.Now()when a vehicle lacks a timestamp.omitzerotags to the exclusiveVehicleStatusmodel fields.TripStatus: Implemented a customMarshalJSONwrapper strictly within thevehicles-for-agencyhandler. This strips zero-valued time fields from the nestedtripStatusfor this endpoint only.Why this approach?
As noted in the issue, applying a global omission tag to the shared
models.TripStatuswould break the API contract for other endpoints (e.g.,trips-for-route) which explicitly require these fields to serialize as0. This wrapper isolates the fix tovehicles-for-agency.Testing
tripStatus.TripStatusremain unaffected.Closes: #1115
Summary by CodeRabbit