Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for DSJ in transit leg reference #5455

Merged

Conversation

vpaturet
Copy link
Contributor

@vpaturet vpaturet commented Oct 25, 2023

Summary

As detailed in #5422, a transit leg reference should refer to a TripOnServiceDate id (i.e. dated service journey id) when one exists,
since a dated service journey provides a more stable id across deliveries of planned data.

The PR introduces also a builder for ScheduledTransitLeg and FrequencyTransitLeg.

Issue

Closes #5422

Unit tests

Added unit tests

Documentation

No

@vpaturet vpaturet self-assigned this Oct 25, 2023
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Attention: 36 lines in your changes are missing coverage. Please review.

Comparison is base (8394b7c) 66.82% compared to head (07ec689) 66.88%.
Report is 6 commits behind head on dev-2.x.

❗ Current head 07ec689 differs from pull request most recent head ef5f54c. Consider uploading reports for the commit ef5f54c to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5455      +/-   ##
=============================================
+ Coverage      66.82%   66.88%   +0.06%     
- Complexity     15473    15517      +44     
=============================================
  Files           1798     1800       +2     
  Lines          69804    69906     +102     
  Branches        7359     7361       +2     
=============================================
+ Hits           46646    46758     +112     
+ Misses         20702    20692      -10     
  Partials        2456     2456              
Files Coverage Δ
...tripplanner/ext/fares/impl/DefaultFareService.java 94.44% <100.00%> (+2.21%) ⬆️
...pplanner/ext/fares/model/FareAttributeBuilder.java 72.41% <ø> (-0.76%) ⬇️
...planner/ext/realtimeresolver/RealtimeResolver.java 83.87% <100.00%> (-2.98%) ⬇️
...ntripplanner/gtfs/mapping/FareAttributeMapper.java 95.00% <100.00%> (ø)
...planner/model/plan/ScheduledTransitLegBuilder.java 100.00% <100.00%> (ø)
...nner/model/plan/legreference/LegReferenceType.java 89.47% <100.00%> (+0.58%) ⬆️
...lan/legreference/ScheduledTransitLegReference.java 86.58% <100.00%> (+4.91%) ⬆️
...anner/routing/alternativelegs/AlternativeLegs.java 92.17% <100.00%> (+0.99%) ⬆️
...opentripplanner/ext/fares/impl/HSLFareService.java 68.26% <50.00%> (ø)
...opentripplanner/ext/fares/model/FareAttribute.java 57.14% <50.00%> (-0.76%) ⬇️
... and 7 more

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vpaturet vpaturet force-pushed the add_support_for_dsj_in_leg_reference branch from 073923e to 3c3e59c Compare October 25, 2023 14:56
@vpaturet vpaturet marked this pull request as ready for review October 25, 2023 14:57
@vpaturet vpaturet requested a review from a team as a code owner October 25, 2023 14:57
@vpaturet vpaturet force-pushed the add_support_for_dsj_in_leg_reference branch from 3c3e59c to 07ec689 Compare October 25, 2023 14:59
@leonardehrenfried leonardehrenfried requested review from leonardehrenfried and t2gran and removed request for leonardehrenfried and t2gran October 26, 2023 14:13
@vpaturet vpaturet force-pushed the add_support_for_dsj_in_leg_reference branch from 07ec689 to ef5f54c Compare October 26, 2023 16:47
@vpaturet
Copy link
Contributor Author

vpaturet commented Oct 27, 2023

This implementation guarantees backward compatibility (newer versions of OTP can parse tokens generated by previous versions of OTP), but not forward compatibility (an older version of OTP would fail when attempting to deserialize a token generated by a newer version). This is due to the deserializer attempting to resolve the token version as a Java enum, which is missing in older versions of the class.
This issue may arise when running a rolling update in a cloud environment, where both the old and new version of OTP are running simultaneously during a short period.
However, while testing in a production-like environment, the error did not occur: leg references are most likely used over longer periods than a typical rollout time (in other words: the leg reference is queried long enough after the token was created).

The conclusion is that:

  • forward compatibility is a minor, non-blocking issue in regard to the more serious consistency issues that this PR intends to fix.
  • the versioning mechanism should be revisited as suggested in Create a reusable token generator #5451

@@ -45,8 +52,8 @@ enum LegReferenceType {
/**
* Return the latest LegReferenceType version for a given leg reference class.
*/
static LegReferenceType forClass(Class<? extends LegReference> legReferenceClass) {
Optional<LegReferenceType> latestVersion = Arrays
static Optional<LegReferenceType> forClass(Class<? extends LegReference> legReferenceClass) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@t2gran t2gran added this to the 2.5 (next release) milestone Oct 27, 2023
@vpaturet vpaturet merged commit ea1edcd into opentripplanner:dev-2.x Oct 30, 2023
5 checks passed
t2gran pushed a commit that referenced this pull request Oct 30, 2023
@t2gran t2gran deleted the add_support_for_dsj_in_leg_reference branch November 21, 2023 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Leg ID does not have DatedServiceJourney ID, only ServiceJourney ID
3 participants