Fix block-level cache contamination#465
Conversation
📝 WalkthroughWalkthroughThis PR adds a ChangesRealtime trip applicability filtering
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant AbstractBlockLocationServiceImpl
participant BlockLocation
participant ArrivalAndDepartureServiceImpl
participant StopTimeInstance
AbstractBlockLocationServiceImpl->>BlockLocation: setRealtimeTripId(record.getTripId())
ArrivalAndDepartureServiceImpl->>BlockLocation: getRealtimeTripId()
ArrivalAndDepartureServiceImpl->>ArrivalAndDepartureServiceImpl: isBlockLocationApplicableToInstance(location, instance)
ArrivalAndDepartureServiceImpl->>StopTimeInstance: compare trip id / check timepoint predictions
alt location applicable
ArrivalAndDepartureServiceImpl->>ArrivalAndDepartureServiceImpl: apply realtime prediction to instance
else no applicable location
ArrivalAndDepartureServiceImpl->>ArrivalAndDepartureServiceImpl: fall back to schedule-based instance
end
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
|
This CLA is wrong - it's currently displaying the default SAP SE corporate template. |
|
cc @aaronbrethorst - seems you added CONTRIBUTING.md referencing the CLA, but the CLA is wrong ("to SAP"):
|
As reported in #216 (this PR fixes #216) and suffered by me and other transit apps, if any trip on a block had GTFS‑RT data, the cache returned a non‑empty location list, and
predicted=trueleaked to every trip on that block even if they had no RT data.The fix adds a
realtimeTripIdfield toBlockLocation- it records which trip the GTFS‑RT data actually belongs to. Then inapplyRealTimeToStopTimeInstance, it checksisBlockLocationApplicableToInstance:The check says: a BlockLocation is "applicable" to a trip if either:
realtimeTripIdmatches this tripOtherwise the trip falls through to the scheduled‑only path, which produces
predicted=false. No more schedule data wearing thepredicted=truebadge just because a different trip on the same block has real‑time data.Disclosure: Generated by GPT-5.5.
Summary by CodeRabbit