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

voi_de: remove bicycle #143

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

The changelog lists relevant feature changes between each release. Search GitHub issues and pull requests for smaller issues.

## [unreleased]
- add converter for api.voiapp.io/gbfs/v2 feed: remove all voi_bike entries

## 2024-11-12
- add converter for `gbfs.prod.sharedmobility.ch/v2/gbfs/pickebike_basel` feed: set valid pricing_plan_id

Expand Down
1 change: 1 addition & 0 deletions app/converters/gbfs_https_to_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class GbfsHttpsToHttpConverter(BaseConverter):
'data.lime.bike',
'mds.bird.co',
'gbfs.prod.sharedmobility.ch',
'api.voiapp.io',
]

def convert(self, data: Union[dict, list], path: str) -> Union[dict, list]:
Expand Down
49 changes: 49 additions & 0 deletions app/converters/gbfs_voi_de_remove_bicycle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from typing import List, Union

from app.base_converter import BaseConverter


class GbfsVoiDeRemoveBicycleConverter(BaseConverter):
"""
voi_de contains no bicycles, so we can remove all voi_bike entries.
"""

hostnames = ['api.voiapp.io']

def convert(self, data: Union[dict, list], path: str) -> Union[dict, list]:
if not isinstance(data, dict):
return data

if path.endswith('/vehicle_types.json'):
fields = data.get('data', {})
if not isinstance(fields, dict):
return data
vehicle_types = fields.get('vehicle_types', [])
if not isinstance(vehicle_types, list):
return data
newlist = []
for vehicle_type in vehicle_types:
if vehicle_type.get('vehicle_type_id') != 'voi_bike':
newlist.append(vehicle_type)
fields['vehicle_types'] = newlist
return data

if path.endswith('/station_status.json'):
fields = data.get('data', {})
if not isinstance(fields, dict):
return data
stations = fields.get('stations', [])
if not isinstance(stations, list):
return data
for station in stations:
vehicle_types_available = station.get('vehicle_types_available', [])
if not isinstance(vehicle_types_available, list):
continue
newlist = []
for vehicle_type_available in vehicle_types_available:
if vehicle_type_available.get('vehicle_type_id') != 'voi_bike':
newlist.append(vehicle_type_available)
station['vehicle_types_available'] = newlist
return data

return data
1 change: 1 addition & 0 deletions config_dist_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ HTTP_TO_HTTPS_HOSTS:
- data.lime.bike
- mds.bird.co
- gbfs.prod.sharedmobility.ch
- api.voiapp.io
Loading