Skip to content

Commit

Permalink
add currentRangeMeters to VehicleRentalVehicle and gtfs graphql API
Browse files Browse the repository at this point in the history
  • Loading branch information
JustCris654 committed Nov 22, 2024
1 parent 136e03d commit 2eef86c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public DataFetcher<Double> currentFuelPercent() {
return environment -> getSource(environment).getCurrentFuelPercent();
}

@Override
public DataFetcher<Double> currentRangeMeters() {
return environment -> getSource(environment).getCurrentRangeMeters();
}

@Override
public DataFetcher<Relay.ResolvedGlobalId> id() {
return environment ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,8 @@ public interface GraphQLRentalVehicle {

public DataFetcher<Double> currentFuelPercent();

public DataFetcher<Double> currentRangeMeters();

public DataFetcher<graphql.relay.Relay.ResolvedGlobalId> id();

public DataFetcher<Double> lat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,8 @@ public VehicleRentalSystem getVehicleRentalSystem() {
public Double getCurrentFuelPercent() {
return currentFuelPercent;
}

public Double getCurrentRangeMeters() {
return currentRangeMeters;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public VehicleRentalVehicle mapFreeVehicleStatus(GBFSBike vehicle) {
? Instant.ofEpochSecond((long) (double) vehicle.getLastReported())
: null;
rentalVehicle.currentRangeMeters = vehicle.getCurrentRangeMeters();
rentalVehicle.currentFuelPercent = vehicle.getCurrentFuelPercent();
rentalVehicle.pricingPlanId = vehicle.getPricingPlanId();
GBFSRentalUris rentalUris = vehicle.getRentalUris();
if (rentalUris != null) {
Expand All @@ -61,7 +62,6 @@ public VehicleRentalVehicle mapFreeVehicleStatus(GBFSBike vehicle) {
String webUri = rentalUris.getWeb();
rentalVehicle.rentalUris = new VehicleRentalStationUris(androidUri, iosUri, webUri);
}
rentalVehicle.currentFuelPercent = vehicle.getCurrentFuelPercent();

return rentalVehicle;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1801,8 +1801,10 @@ type RealTimeEstimate {
type RentalVehicle implements Node & PlaceInterface {
"If true, vehicle is currently available for renting."
allowPickupNow: Boolean
"Current fuel percentage of the free floating vehicle. Value expressed from 0 to 1"
"Fuel or battery power remaining in the vehicle. Expressed from 0 to 1."
currentFuelPercent: Float
"Range in meters that the vehicle can travel with the vehicle's current charge or fuel."
currentRangeMeters: Float
"Global object ID provided by Relay. This value can be used to refetch this object using **node** query."
id: ID!
"Latitude of the vehicle (WGS 84)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ public class TestFreeFloatingRentalVehicleBuilder {
public static final double DEFAULT_LATITUDE = 47.520;
public static final double DEFAULT_LONGITUDE = 19.01;
public static final double DEFAULT_CURRENT_FUEL_PERCENT = 0.5;
public static final double DEFAULT_CURRENT_RANGE_METERS = 5500;

private double latitude = DEFAULT_LATITUDE;
private double longitude = DEFAULT_LONGITUDE;
private double currentFuelPercent = DEFAULT_CURRENT_FUEL_PERCENT;
private double currentRangeMeters = DEFAULT_CURRENT_RANGE_METERS;
private VehicleRentalSystem system = null;

private RentalVehicleType vehicleType = RentalVehicleType.getDefaultType(NETWORK_1);
Expand All @@ -37,6 +39,11 @@ public TestFreeFloatingRentalVehicleBuilder withCurrentFuelPercent(double curren
return this;
}

public TestFreeFloatingRentalVehicleBuilder withCurrentRangeMeters(double currentRangeMeters) {
this.currentRangeMeters = currentRangeMeters;
return this;
}

public TestFreeFloatingRentalVehicleBuilder withSystem(String id, String url) {
this.system =
new VehicleRentalSystem(
Expand Down Expand Up @@ -93,6 +100,7 @@ public VehicleRentalVehicle build() {
vehicle.vehicleType = vehicleType;
vehicle.system = system;
vehicle.currentFuelPercent = currentFuelPercent;
vehicle.currentRangeMeters = currentRangeMeters;
return vehicle;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"networkId":"Network-1",
"url":"https://foo.bar"
},
"currentFuelPercent": 0.5
"currentFuelPercent": 0.5,
"currentRangeMeters": 5500.0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
url
}
currentFuelPercent
currentRangeMeters
}
}

0 comments on commit 2eef86c

Please sign in to comment.