From 28a7bbd4f39ac26e0fb205aa6319ec9341a8ab4c Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Thu, 29 Dec 2022 13:40:47 +0100 Subject: [PATCH] Skip timeseries without recent data --- dashboard.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dashboard.py b/dashboard.py index 5cf84bb..c4da931 100644 --- a/dashboard.py +++ b/dashboard.py @@ -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: