Skip to content

Commit

Permalink
Cleanup and document code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamarar committed Feb 17, 2018
1 parent a53ac1a commit 5551263
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ $ docker run -d -p 8080:8080 velo
## Contributing

Send PR.

## Disclaimer
I'm not a professional developer.
14 changes: 14 additions & 0 deletions Station.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"id":"001",
"lon":"4.420650000000000000",
"lat":"51.217820000000000000",
"bikes":"0",
"slots":"31",
"zip":"2018",
"address":"Koningin Astridplein",
"status":"OPN",
"name":"001- Centraal Station - Astrid",
"stationType":"BIKE"
}
]
9 changes: 3 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func init() {
}

// Station holds all the data that a single station has.
// See Station.json for how the original looks like.
type Station struct {
ID string `json:"id"`
District string `json:"-"`
Expand Down Expand Up @@ -82,6 +83,7 @@ func (v *VeloManager) GetStations() (bikesByStation map[string]int, slotsByStati
slots := Stations[idx].Slots
name := Stations[idx].Name

// Convert json string to int.
iBikes, err := strconv.Atoi(bike)
if err != nil {
log.Printf("Error strconv bike: %v", err)
Expand All @@ -99,12 +101,6 @@ func (v *VeloManager) GetStations() (bikesByStation map[string]int, slotsByStati
end := time.Now()
log.Printf("Duration: %v", end.Sub(start))

// bikesByStation["045-Falconplein"] = 12
// bikesByStation["046-Somewhere"] = 14

// slotsByStation["045-Falconplain"] = 8
// slotsByStation["046-Somewhere"] = 6

return
}

Expand Down Expand Up @@ -162,6 +158,7 @@ func main() {
flag.Parse()

log.Printf("Pushing metrics on port: %v", *addr)

// Expose the registered metrics via HTTP.
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(*addr, nil))
Expand Down

0 comments on commit 5551263

Please sign in to comment.