Skip timeseries without recent data

This commit is contained in:
Peter J. Holzer 2022-12-29 13:40:47 +01:00 committed by Peter J. Holzer
parent 851d9b4b37
commit 28a7bbd4f3
1 changed files with 8 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import json
import logging
import time
from flask import (Flask, request, jsonify, abort, render_template_string, render_template)
from markupsafe import Markup
@ -23,6 +24,13 @@ class Dashboard:
if w.get("multi"):
ts_list = LTS.find(w["data"][0])
for ts in ts_list:
tso = LTS(id=ts)
if not tso.data:
log.warning("%s has no data: Skipping", tso.id)
continue
if tso.data[-1][0] < time.time() - 86400:
log.info("%s too old; Skipping", tso.id)
continue
w1 = {**w, "data": [ts]}
self.widgets.append(Gauge(w1))
else: