-
Notifications
You must be signed in to change notification settings - Fork 170
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
Add Pedalada by Share2Go system #746
Conversation
Hello! Thanks for contributing.
I think it's fine as it is if the extra-extra request only has an address. We have other systems like these on which each station needs a request to get status data. I think it does not need many changes, can you take a look? See: pybikes/fsm.py and pybikes/bicincitta.py Let me know if you need anything, ask away |
Hello! Did not notice stations could have an update method too. I'll fix that. About the address stuff, there are a bunch of "endpoints" for getting data on stations.
I'm only using the last one because it includes most info, including bikes. Also there's some stations with a schedule, I don't know how you'd like me to format that. I was thinking of formatting it like the opening_hours property on OSM (00:00 - 23:59). Let me know what you think I should do. There's also values that list inactive docks and docks in maintenance. Do you think that data should be included too? Thanks! |
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.
Couple of issues with the implementation. We can keep reviewing after these are fixed. Thanks!
You can try if this implementation passes the update tests by running the following.
pytest -k pedalada -vvv
More info on running tests here
Yup, my bad. All fixed now! Thanks again |
'online': data['state'] == 1, | ||
'photo': station_image_url(endpoint, data['stationNumber']), | ||
'open': data['stationIsOpen'] == 1, | ||
'in_maintenance': data['stationInMaintenance'] == 1 |
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.
Do you know the difference between state
, stationIsOpen
and stationInMaintenance
?
In vitelinhas there's one station with the following:
{
"name": "Avenida da Liberdade",
"latitude": 41.45442,
"longitude": -8.17702,
"bikes": 3,
"free": 8,
"extra": {
"uid": 2,
"slots": 11,
"online": false,
"photo": "https://vitelinhas.cm-fafe.pt/images/stations/station_2.jpg",
"open": true,
"in_maintenance": false
},
"type": "station",
"tag": "vitelinhas"
}
On the website that's reported as inactive. So my take on there is that open maybe means it's within the schedule opening hours?
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.
My take is that it's a bit confusing and we should try to find a better name for it, or decide to not include it if we skip schedules altogether
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.
Do you know the difference between
state
,stationIsOpen
andstationInMaintenance
?In vitelinhas there's one station with the following:
{ "name": "Avenida da Liberdade", "latitude": 41.45442, "longitude": -8.17702, "bikes": 3, "free": 8, "extra": { "uid": 2, "slots": 11, "online": false, "photo": "https://vitelinhas.cm-fafe.pt/images/stations/station_2.jpg", "open": true, "in_maintenance": false }, "type": "station", "tag": "vitelinhas" }
On the website that's reported as inactive. So my take on there is that open maybe means it's within the schedule opening hours?
open means that the station would be open according to its schedule. But it can be unavailable due to connection problems but would be open per se.
On the websites, the station being offline takes precedence over the schedules and if it is offline it's just shown as inactive.
I believe a station in maintenance means that it is not available at the moment, due to being serviced, but will be back available once the maintenance is finished. Maybe we could combine these all into one property.
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 partly fault on pybikes side that we do not have a full specification for such cases. For some we have a status
field that is a kind of all goes in. We could try to merge open
and in_maintenance
with the status
field with one of the following open
, closed
, maintenance
. Since we can consider that a station that is in maintenance is not open nor closed per se.
def format_status(self, data):
if data['stationInMaintenance']:
return 'maintenance'
elif data['stationIsOpen']:
return 'open'
else:
return 'closed'
[...]
'status': self.format_status(data),
Alternatively we can go with a oneliner but it's a bit of weird python
'status': 'maintenance' if data['stationInMaintenance'] else 'open' if data['stationIsOpen'] else 'closed'
@joaodcp any progress on this PR? I feel we are good to merge once this #746 (comment) goes in |
Integrated changes from this branch over #755 |
Hi,
This adds a system deployed in Portugal called Pedalada by a company named Share2Go.
The station address is not included because it takes an extra request per station to retrieve (the details in 'get-station-details-and-ride.php' are not the same as in 'get-station-details.php'). One request per station is already needed to get the number of docked bikes; if you think an extra request per station to get one additional property is worth it then I can implement that.
Thanks again for this great project!