check_nodes: tune query
This commit is contained in:
parent
dac9b4ac2f
commit
ac79afe97a
|
|
@ -290,9 +290,8 @@ func getLastMetrics(deveui string) OneMetric {
|
|||
data := []byte(fmt.Sprintf(`from(bucket:"wobischbucket")
|
||||
|> range(start:-5d)
|
||||
|> filter(fn: (r) => r._measurement == "measurement" and r.deveui == "%s")
|
||||
|> filter(fn: (r) => r._field == "lon" or r._field == "lat" or r._field == "vbat" or r._field == "fw")
|
||||
|> last(column: "_time")
|
||||
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")`, deveui))
|
||||
|> filter(fn: (r) => r._field == "vbat")
|
||||
|> last(column: "_time")`, deveui))
|
||||
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
|
|
@ -329,7 +328,8 @@ func getLastMetrics(deveui string) OneMetric {
|
|||
location, err := time.LoadLocation("Europe/Zurich")
|
||||
for scanner.Scan() {
|
||||
s := strings.Split(scanner.Text(), ",")
|
||||
if (len(s) >= 9) && !(strings.HasPrefix(s[3], "_")) {
|
||||
//fmt.Printf("s: %q\n", s)
|
||||
if (len(s) >= 7) && !(strings.HasPrefix(s[3], "_")) {
|
||||
t, err := time.Parse(time.RFC3339, s[5])
|
||||
if err != nil {
|
||||
fmt.Printf("error converting time: %s\n", s[5])
|
||||
|
|
@ -337,7 +337,8 @@ func getLastMetrics(deveui string) OneMetric {
|
|||
}
|
||||
|
||||
res.Timestamp = t.In(location).Format("02.01.2006 15:04")
|
||||
res.BatteryPercent = strconv.Itoa(vbat2percent(s[8]))
|
||||
res.BatteryPercent = strconv.Itoa(vbat2percent(s[6]))
|
||||
fmt.Printf("vbat: %s\n", s[6])
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue