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 HSL specific fare computation in the sandbox #4414

Merged
merged 26 commits into from
Sep 12, 2022

Conversation

nurmAV
Copy link
Contributor

@nurmAV nurmAV commented Aug 25, 2022

Summary

Adds HSL specific fare computation previously implemented in the HSL fork for OTP 1.

  • Implements the HSLFareServiceImpl and HSLFareServiceFactory that override the default implementation to fit HSL needs
  • Implements the ticket type query in the legacy GraphQL API
  • Adds some new data structures to support HSL specific fare rules and makes some methods it the default implementations protected instead of private so that they can be overridden.

Unit tests

  • The changes include new unit tests for HSL fares
  • The correctness of the fares output has also been validated using the HSL journey planner UI.

@nurmAV nurmAV requested a review from a team as a code owner August 25, 2022 12:20
@@ -33,9 +37,20 @@ public Set<P2<String>> getOriginDestinations() {
return originDestinations;
}

public void addRouteOriginDestination(String route, String origin, String destination) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add some information about what these methods mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used for special routes in HSL where some tickets can be used outside the HSL service area when travelling between some origin and destination on a certain route. All three pieces of information are needed for determining whether a special route rule needs to be applied when computing fare information

@leonardehrenfried
Copy link
Member

You need to reformat your code with mvn prettier:write.

@hannesj hannesj added New Feature GTFS Related to import of GTFS data Sandbox Skip Changelog labels Aug 25, 2022
@hannesj
Copy link
Contributor

hannesj commented Aug 25, 2022

Please add documentation

@leonardehrenfried
Copy link
Member

@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2022

Codecov Report

Merging #4414 (d4d4869) into dev-2.x (b23dcbc) will decrease coverage by 0.04%.
The diff coverage is 38.81%.

@@              Coverage Diff              @@
##             dev-2.x    #4414      +/-   ##
=============================================
- Coverage      58.21%   58.16%   -0.05%     
- Complexity     11204    11229      +25     
=============================================
  Files           1480     1484       +4     
  Lines          59173    59331     +158     
  Branches        6783     6813      +30     
=============================================
+ Hits           34445    34508      +63     
- Misses         22667    22759      +92     
- Partials        2061     2064       +3     
Impacted Files Coverage Δ
.../opentripplanner/ext/fares/FaresConfiguration.java 43.33% <0.00%> (-1.50%) ⬇️
...nner/ext/fares/impl/DefaultFareServiceFactory.java 85.36% <ø> (ø)
...planner/ext/fares/impl/DefaultFareServiceImpl.java 89.82% <0.00%> (-0.55%) ⬇️
...pplanner/ext/fares/impl/HSLFareServiceFactory.java 0.00% <0.00%> (ø)
...pl/HighestFareInFreeTransferWindowFareService.java 92.00% <ø> (ø)
...estFareInFreeTransferWindowFareServiceFactory.java 84.61% <ø> (ø)
...ipplanner/ext/fares/impl/SFBayFareServiceImpl.java 0.00% <ø> (ø)
.../legacygraphqlapi/LegacyGraphQLRequestContext.java 0.00% <0.00%> (ø)
...pi/datafetchers/LegacyGraphQLNodeTypeResolver.java 2.08% <ø> (ø)
...raphqlapi/generated/LegacyGraphQLDataFetchers.java 0.00% <ø> (ø)
... and 23 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.


import java.io.Serializable;

public record RouteOriginDestination(String route, String origin, String destination)
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to org.opentripplanner.ext.fares.model

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that would cause the FareRuleSet in org.opentripplanner.routing.core to refer to this class in ext. Is that ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is ok, it already has a reference to org.opentripplanner.ext.fares.model.FareAttribute

Copy link
Contributor

@hannesj hannesj Sep 6, 2022

Choose a reason for hiding this comment

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

Actually, the entire FareRuleSet could be moved to org.opentripplanner.ext.fares.model, as it is only used by sandbox extensions.

Copy link
Contributor

@hannesj hannesj left a comment

Choose a reason for hiding this comment

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

Couple of small things

@leonardehrenfried leonardehrenfried added the bump serialization id Add this label if you want the serialization id automatically bumped after merging the PR label Sep 1, 2022
@leonardehrenfried
Copy link
Member

You need to run mvn prettier:write.

@hannesj hannesj self-requested a review September 1, 2022 13:30
@@ -2,16 +2,23 @@
package org.opentripplanner.ext.legacygraphqlapi.generated;

import graphql.relay.Connection;
import graphql.relay.Connection;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you run intelliJ "Optimize imports" for this file

@hannesj
Copy link
Contributor

hannesj commented Sep 6, 2022

It seems you need to merge in master, as there are some small conflicts with work in #4338

hannesj
hannesj previously approved these changes Sep 6, 2022
@nurmAV
Copy link
Contributor Author

nurmAV commented Sep 6, 2022

I found a ClassCastException, that should be fixed before this is merged

@leonardehrenfried
Copy link
Member

If hsl want to merge this before I'm back from my holiday, I nominate Joel or Vesa to take over my review. ( Last time I checked there were only superficial issues left.)

@vesameskanen vesameskanen dismissed leonardehrenfried’s stale review September 12, 2022 12:39

P3 and T3 are converted to named records

@vesameskanen vesameskanen merged commit 807734a into opentripplanner:dev-2.x Sep 12, 2022
@vesameskanen vesameskanen deleted the hsl_fares branch September 12, 2022 12:40
t2gran pushed a commit that referenced this pull request Sep 12, 2022
@t2gran t2gran added this to the 2.2 milestone Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump serialization id Add this label if you want the serialization id automatically bumped after merging the PR GTFS Related to import of GTFS data New Feature Sandbox Skip Changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants