Skip to content

Commit

Permalink
only send future forecasts > 1 hour from now, not times in the past
Browse files Browse the repository at this point in the history
This makes it so period=past and period=future don't end up overlapping
  • Loading branch information
Ted Pearson committed Dec 11, 2021
1 parent 5f912e8 commit 10fc020
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions weather/forecast.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func toPoints(items []interface{}, options WriteOptions) (influxdb1.BatchPoints,
}
for _, item := range items {
t := reflect.ValueOf(item).FieldByName("Time").Interface().(time.Time)
// only send future datapoints.
if t.Before(time.Now().Add(time.Hour + 1)) {
continue
}
point, err := toPoint(t, item, options)
if err != nil {
log.Printf("Failed to create point: %+v", err)
Expand Down

0 comments on commit 10fc020

Please sign in to comment.