-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Filter import of rental data by pickup type #6240
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
Filter import of rental data by pickup type #6240
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6240 +/- ##
==========================================
Coverage 69.71% 69.71%
- Complexity 17696 17702 +6
==========================================
Files 2008 2009 +1
Lines 75834 75857 +23
Branches 7765 7766 +1
==========================================
+ Hits 52866 52886 +20
- Misses 20256 20258 +2
- Partials 2712 2713 +1 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
| .summary("The type of rental data to include.") | ||
| .description( | ||
| """ | ||
| The type of rental data to include. This can be one of the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify that this parameter is only temporary and it's going to be removed.
| params.allowedRentalType() == null || | ||
| params.allowedRentalType() == AllowedRentalType.ALL || | ||
| params.allowedRentalType() == AllowedRentalType.STATIONS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could extract this code to be a method inside the params.
| params.allowedRentalType() == null || | ||
| params.allowedRentalType() == AllowedRentalType.ALL || | ||
| params.allowedRentalType() == AllowedRentalType.VEHICLES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above and you could do the OTPFeature.FloatingBike.isOn() check inside the same if.
| @@ -0,0 +1,7 @@ | |||
| package org.opentripplanner.updater; | |||
|
|
|||
| public enum AllowedRentalType { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class should be inside org.opentripplanner.updater.vehicle_rental.datasources.params package.
.../opentripplanner/ext/vehiclerentalservicedirectory/VehicleRentalServiceDirectoryFetcher.java
Outdated
Show resolved
Hide resolved
| @@ -0,0 +1,7 @@ | |||
| package org.opentripplanner.updater.vehicle_rental.datasources.params; | |||
|
|
|||
| public enum AllowedRentalType { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please implement DocumentedEnum which makes it trivial to keep documentation up to date. You can use it like this:
Lines 70 to 77 in f4bfedf
| .withDebug( | |
| c | |
| .of("debug") | |
| .since(V2_0) | |
| .summary(ItineraryFilterDebugProfile.OFF.typeDescription()) | |
| .description(docEnumValueList(ItineraryFilterDebugProfile.values())) | |
| .asEnum(dft.debug()) | |
| ) |
| boolean geofencingZones, | ||
| boolean overloadingAllowed | ||
| boolean overloadingAllowed, | ||
| AllowedRentalType allowedRentalType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write a constructor that makes sure this is never null. Like this:
OpenTripPlanner/application/src/main/java/org/opentripplanner/routing/alertpatch/AlertUrl.java
Lines 7 to 9 in f492446
| public AlertUrl { | |
| Objects.requireNonNull(uri); | |
| } |
doc/user/UpdaterConfig.md
Outdated
| Temporary parameter. The type of rental data to include. | ||
| Temporary parameter. Use this to specify the type of rental data that is allowed to be read from the data source. | ||
|
|
||
| This parameter is temporary and will be removed in a future version of OTP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still be included in some way, probably replace the "Temporary parameter" in the sentence above this with this content..
| * | ||
| * Enum to specify the type of rental data that is allowed to be read from the data source. | ||
| */ | ||
| public enum AllowedRentalType implements DocumentedEnum<AllowedRentalType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@optionsome / @leonardehrenfried What is the right name for this?
I would not include "Allowed" in the name, it restrict the type, so it can not be reused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the "type" (?) of the rental: either free-floating or station-based.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed that we want to use a Set of opt-in rental types. I've used the same pattern when filtering what to import from NeTEx:
Lines 82 to 84 in f4bfedf
| } else if (!ignoredFeatures.contains(FARE_FRAME) && value instanceof FareFrame) { | |
| parse((FareFrame) value, new FareFrameParser()); | |
| } else if (value instanceof CompositeFrame) { |
In our case we probably want to use opt-in rather than opt-out as it's easier to reason about.
| * | ||
| * Enum to specify the type of rental data that is allowed to be read from the data source. | ||
| */ | ||
| public enum AllowedRentalType implements DocumentedEnum<AllowedRentalType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class should be renamed to RentalPickupType and have {STATION, FREE_FLOTING} as values, not ALL.
@leonardehrenfried do you agree? I changed the VEHICLES to FREE_FLOTING. Also use singular, not plural in enums.
In places where there is a set of these you should use Set<RentalPickupType>. I would define a constant in the enum class for ALL like this:
public static final Set<RentalPickupType> ALL = Collections.unmodifiableSet(EnumSet.allOf(RentalPickupType.class));The unmodifiableSet(...) is needed to avoid modification and you should use it instead of Set.copyOf() (witch convert the internal set to a HashSet).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
...ain/java/org/opentripplanner/updater/vehicle_rental/datasources/params/RentalPickupType.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a small request about the documentation.
…rental/datasources/params/RentalPickupType.java Co-authored-by: Leonard Ehrenfried <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I like the enum name or its documentation as it's quite use case specific but the enum is seemingly generic. However, I think we will get rid of the enum soon as well.
Summary
Often only station data or only vehicle data is of interest to our use cases. In those cases the other type of data being read in is unnecessary, inefficient and also problematic, as we get places and routes that are of no value and have to be filtered out on the UI side anyway.
I've added a parameter to the updater configuration, which determines what type of vehicle rental data is read in (stations/vehicles/all).
Unit tests
Documentation