find the temp history for the last week (by default). Smooth out data using aggregate window for hourly numbers. Better temp casting during influx data inflating.
This commit is contained in:
@@ -522,9 +522,9 @@ func (sr *scrutinyRepository) GetSmartTemperatureHistory(ctx context.Context) (m
|
||||
queryStr := fmt.Sprintf(`
|
||||
import "influxdata/influxdb/schema"
|
||||
from(bucket: "%s")
|
||||
|> range(start: -3y, stop: now())
|
||||
|> range(start: -1w, stop: now())
|
||||
|> filter(fn: (r) => r["_measurement"] == "temp" )
|
||||
|> filter(fn: (r) => r["_field"] == "temp")
|
||||
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
|
||||
|> schema.fieldsAsCols()
|
||||
|> group(columns: ["device_wwn"])
|
||||
|> yield(name: "last")
|
||||
|
||||
@@ -24,6 +24,11 @@ func (st *SmartTemperature) Inflate(key string, val interface{}) {
|
||||
}
|
||||
|
||||
if key == "temp" {
|
||||
st.Temp = val.(int64)
|
||||
switch t := val.(type) {
|
||||
case int64:
|
||||
st.Temp = t
|
||||
case float64:
|
||||
st.Temp = int64(t)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user