Skip to content

Commit

Permalink
clean up code and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tedpearson committed Oct 7, 2023
1 parent e44137d commit 2fb0a20
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 25 deletions.
7 changes: 3 additions & 4 deletions dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ func NewDispatcher(forecasters map[string]source.Forecaster, configService *Conf
forecasters: forecasters,
scheduler: scheduler,
configService: configService,
// todo: understand buffered channels.
requests: make(chan Request, 10),
results: make(chan Result, 10),
awaiting: make(map[CacheKey]*[]Request),
requests: make(chan Request, 10),
results: make(chan Result, 10),
awaiting: make(map[CacheKey]*[]Request),
}
go d.runLoop()
return d
Expand Down
11 changes: 0 additions & 11 deletions internal/convert/convert.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package convert

import (
"fmt"
"math"
"strconv"
)

func CToF(celsius float64) float64 {
Expand Down Expand Up @@ -45,12 +43,3 @@ func NilToZero(a *float64) *float64 {
}
return a
}

func StrToF(s string, msg string) float64 {
v, err := strconv.ParseFloat(s, 64)
if err != nil {
fmt.Printf("Unable to parse %s value '%s'\n", msg, s)
v = 0
}
return v
}
7 changes: 3 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
)

var (
version string = "development"
goVersion string = "unknown"
buildDate string = "unknown"
version = "development"
goVersion = "unknown"
buildDate = "unknown"
)

func main() {
Expand Down Expand Up @@ -106,4 +106,3 @@ func MakeForecasters(enabled []string, cacheDir string, vcKey string) map[string

// todo
// update readme
// allow http server functionality to be turned off if desired, by not including a port to listen on or something
2 changes: 1 addition & 1 deletion scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (s Scheduler) Start() {
// run loops and calls updateForecasts at the top of each hour.
func (s Scheduler) run() {
firstRun := time.Now().Truncate(time.Hour)
for _ = range kronika.Every(context.Background(), firstRun, time.Hour) {
for range kronika.Every(context.Background(), firstRun, time.Hour) {
s.updateForecasts()
}
}
Expand Down
4 changes: 0 additions & 4 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,8 @@ func (s *Server) ParseParams(Form url.Values) (*Params, error) {
if err != nil {
return nil, err
}
// fixme: <rfc3339 | unix_timestamp>
// error
start, _ := strconv.ParseInt(Form.Get("start"), 10, 64)
end, _ := strconv.ParseInt(Form.Get("end"), 10, 64)
// fixme: <duration | float>
// error
step, _ := strconv.ParseInt(Form.Get("step"), 10, 64)
return &Params{
Start: start,
Expand Down
2 changes: 1 addition & 1 deletion source/visualcrossing.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (v *VisualCrossing) GetForecast(lat string, lon string) (*Forecast, error)
q.Add("contentType", "json")
q.Add("unitGroup", "us")
q.Add("locationMode", "single")
q.Add("key", v.Key) // todo
q.Add("key", v.Key)
q.Add("location", lat+","+lon)
q.Add("includeAstronomy", "true")
off := backoff.NewExponentialBackOff()
Expand Down

0 comments on commit 2fb0a20

Please sign in to comment.