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

Fix vehicle_types.json wrongly required #85 #86

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions gbfs-validator/gbfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,14 @@ function getPricingPlans({ body }) {
}
}

function hadVehiclesId({ body }) {
function hadVehicleTypeId({ body }) {
if (Array.isArray(body)) {
return body.some(lang => lang.body.data.bikes.find(b => b.vehicle_type_id))
} else {
return body.data.bikes.some(b => b.vehicle_type_id)
}
}

function hasStationId({ body }) {
if (Array.isArray(body)) {
return body.some(lang => lang.body.data.bikes.find(b => b.station_id))
} else {
return body.data.bikes.some(b => b.station_id)
}
}

function hasPricingPlanId({ body }) {
if (Array.isArray(body)) {
return body.some(lang => lang.body.data.bikes.find(b => b.pricing_plan_id))
Expand Down Expand Up @@ -448,10 +440,9 @@ class GBFS {

let vehicleTypes,
pricingPlans,
freeBikeStatusHasVehicleId,
freeBikeStatusHasVehicleTypeId,
hasIosRentalUris,
hasAndroidRentalUris,
hasBikesStationId,
hasBikesPricingPlanId

const result = [gbfsResult]
Expand All @@ -461,14 +452,13 @@ class GBFS {
}

if (fileExist(freeBikeStatusFile)) {
freeBikeStatusHasVehicleId = hadVehiclesId(freeBikeStatusFile)
freeBikeStatusHasVehicleTypeId = hadVehicleTypeId(freeBikeStatusFile)
hasIosRentalUris = hasRentalUris(freeBikeStatusFile, 'bikes', 'ios')
hasAndroidRentalUris = hasRentalUris(
freeBikeStatusFile,
'bikes',
'android'
)
hasBikesStationId = hasStationId(freeBikeStatusFile)
hasBikesPricingPlanId = hasPricingPlanId(freeBikeStatusFile)
}

Expand Down Expand Up @@ -519,7 +509,7 @@ class GBFS {
}
break
case 'vehicle_types':
if (freeBikeStatusHasVehicleId || hasBikesStationId) {
if (freeBikeStatusHasVehicleTypeId) {
required = true
}
if (pricingPlans && pricingPlans.length) {
Expand Down