Add Smoove citybikes updater - #2515
Merged
Merged
Conversation
hannesj
force-pushed
the
smoove-citybikes
branch
4 times, most recently
from
December 7, 2017 13:43
291d83a to
b90fb0f
Compare
laurentg
approved these changes
Dec 10, 2017
t2gran
approved these changes
Jul 23, 2018
t2gran
left a comment
Member
There was a problem hiding this comment.
👍 100% test coverage
👎 Minor code improvement, but not a blocker from my side.
| return null; | ||
| } | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
There is a bit of code duplication node.path("coordinates").asText().split(",") and the try-catch-block is unnecessary wide. The comment on line 69 becomes obsolete if the try catch is narrowed:
public BikeRentalStation makeStation(JsonNode node) {
BikeRentalStation station = new BikeRentalStation();
station.id = node.path("name").asText().split("\\s", 2)[0];
station.name = new NonLocalizedString(node.path("name").asText().split("\\s", 2)[1]);
try {
String[] coordinatesAsString = node.path("coordinates").asText().split(",");
station.y = Double.parseDouble(coordinatesAsString[0].trim());
station.x = Double.parseDouble(coordinatesAsString[1].trim());
} catch (NumberFormatException e) {
log.warn("Error parsing bike rental station " + station.id, e);
return null;
}
if (!node.path("operative").asText().equals("true")) {
station.bikesAvailable = 0;
station.spacesAvailable = 0;
} else {
station.bikesAvailable = node.path("avl_bikes").asInt();
station.spacesAvailable = node.path("free_slots").asInt();
}
return station;
}
``
`
Contributor
Author
|
@t2gran I updated the code according to your comments. Would it be possible to merge? |
hannesj
force-pushed
the
smoove-citybikes
branch
from
August 20, 2018 13:29
707dfff to
7ae1a0d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new updater for Smoove bike rental systems.
Example api endpoint is http://helsinki-fi.smoove.pro/api-public/stations