Skip to content

Conversation

@sharhio
Copy link
Contributor

@sharhio sharhio commented Nov 7, 2024

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

  • Updated related tests with the new parameter value.
  • Manually tested.

Documentation

  • Updater config documentation updated.

@sharhio sharhio requested a review from a team as a code owner November 7, 2024 12:21
@codecov
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 86.36364% with 6 lines in your changes missing coverage. Please review.

Project coverage is 69.71%. Comparing base (5b5d92f) to head (7735de7).
Report is 17 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...ental/datasources/GbfsVehicleRentalDataSource.java 84.21% 0 Missing and 3 partials ⚠️
...g/updaters/sources/VehicleRentalSourceFactory.java 80.00% 2 Missing ⚠️
...kerental/SmooveBikeRentalDataSourceParameters.java 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@optionsome optionsome added the Digitransit Test Feature is under testing in Digitransit environment(s) label Nov 7, 2024
@optionsome optionsome requested review from leonardehrenfried, optionsome and t2gran and removed request for optionsome November 7, 2024 16:17
.summary("The type of rental data to include.")
.description(
"""
The type of rental data to include. This can be one of the following:
Copy link
Member

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.

Comment on lines 81 to 83
params.allowedRentalType() == null ||
params.allowedRentalType() == AllowedRentalType.ALL ||
params.allowedRentalType() == AllowedRentalType.STATIONS
Copy link
Member

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.

Comment on lines 121 to 123
params.allowedRentalType() == null ||
params.allowedRentalType() == AllowedRentalType.ALL ||
params.allowedRentalType() == AllowedRentalType.VEHICLES
Copy link
Member

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 {
Copy link
Member

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.

@t2gran t2gran changed the title Filtering the type of vehicle rental data read in Filtering the type of vehicle rental data imported real time Nov 12, 2024
@t2gran t2gran added this to the 2.7 (next release) milestone Nov 12, 2024
@leonardehrenfried leonardehrenfried changed the title Filtering the type of vehicle rental data imported real time Filter rental data by vehicle type Nov 12, 2024
@leonardehrenfried leonardehrenfried changed the title Filter rental data by vehicle type Filter import of rental data by vehicle type Nov 12, 2024
@@ -0,0 +1,7 @@
package org.opentripplanner.updater.vehicle_rental.datasources.params;

public enum AllowedRentalType {
Copy link
Member

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:

.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
Copy link
Member

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:

public AlertUrl {
Objects.requireNonNull(uri);
}

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.
Copy link
Member

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..

optionsome
optionsome previously approved these changes Nov 15, 2024
*
* Enum to specify the type of rental data that is allowed to be read from the data source.
*/
public enum AllowedRentalType implements DocumentedEnum<AllowedRentalType> {
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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:

} 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> {
Copy link
Member

@t2gran t2gran Nov 19, 2024

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).

Copy link
Member

Choose a reason for hiding this comment

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

I agree.

Copy link
Member

@leonardehrenfried leonardehrenfried left a 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.

sharhio and others added 2 commits November 20, 2024 13:19
…rental/datasources/params/RentalPickupType.java

Co-authored-by: Leonard Ehrenfried <[email protected]>
@leonardehrenfried leonardehrenfried changed the title Filter import of rental data by vehicle type Filter import of rental data by pickup type Nov 21, 2024
Copy link
Member

@optionsome optionsome left a 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.

@optionsome optionsome merged commit a6c3d52 into opentripplanner:dev-2.x Nov 21, 2024
5 checks passed
t2gran pushed a commit that referenced this pull request Nov 21, 2024
@optionsome optionsome deleted the filter-updater-data branch November 21, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Digitransit Test Feature is under testing in Digitransit environment(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants