Validate stop id in Transit leg reference - #5440
Conversation
dc73bdd to
fff75a1
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5440 +/- ##
=============================================
+ Coverage 66.67% 66.81% +0.13%
- Complexity 15396 15470 +74
=============================================
Files 1794 1798 +4
Lines 69683 69808 +125
Branches 7345 7360 +15
=============================================
+ Hits 46462 46641 +179
+ Misses 20758 20711 -47
+ Partials 2463 2456 -7
☔ View full report in Codecov by Sentry. |
fff75a1 to
c2be864
Compare
leonardehrenfried
left a comment
There was a problem hiding this comment.
Please have a look at my comments.
|
Added a more robust versioning logic. This will make it easier to implement further modifications in the leg serialized id structure |
| ScheduledTransitLegReference.class, | ||
| LegReferenceSerializer::writeScheduledTransitLegV2, | ||
| LegReferenceSerializer::readScheduledTransitLegV2 | ||
| ); |
There was a problem hiding this comment.
The design is a bit awkward. But, we can leave it for now. I would love to make a common TokenSerializer witch encapsulate the read/write operations, version and base64 encoding. This should be used in paging as well. I think I will create a task for it.
Summary
As detailed in #5423, transit leg references currently refer to stop position, not stop id: if the trip pattern is changed by a real-time update, the leg reference could point to the wrong physical stop.
This PR verifies that the referenced stop positions still refer to the same stop ids in the actual pattern.
As an exception, the reference is considered valid if the referenced stop is different but belongs to the same parent station: this covers for example the case of a last-minute platform change in a train station that typically does not affect the validity of the leg.
This PR modifies the structure of the serialized leg id by adding new fields, but guarantees that existing (legacy) references will be deserialized successfully.
Issue
Partially addresses #5423
Unit tests
Added unit tests
Documentation
No