From 38aae30892fa6e94f5f5458777ee3933003eece2 Mon Sep 17 00:00:00 2001 From: Brosef Date: Sat, 7 Mar 2026 18:45:57 +0000 Subject: [PATCH] Fixed bug with 24h counter failing on new db --- blueprints/booper.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/blueprints/booper.py b/blueprints/booper.py index ef975f6..565ebc2 100644 --- a/blueprints/booper.py +++ b/blueprints/booper.py @@ -155,6 +155,9 @@ class Blueprint(flask.Blueprint): (name,)).fetchone() self._totalBoops[name] = totalData['count'] + # Initialise 24h counts with registered names + self._boops24h = {name: [] for name in self.registeredNames} + # Load all boops from the past 24h boops24h = db.GLOBAL.execute('SELECT * FROM booper WHERE total=0 AND startTime>=?', (time.time()-86400,)).fetchall() @@ -163,11 +166,13 @@ class Blueprint(flask.Blueprint): count = row['count'] ts = row['startTime'] - if name not in self._boops24h: - self._boops24h.update({name: []}) - self._boops24h[name].append({'ts': ts, 'count': count}) + # Fix empty recents + for name in self._boops24h: + if self._boops24h[name] == []: + self._boops24h[name].append({'ts': round(time.time()), 'count': 0}) + self._workerThread = Thread(target=self._worker) self._workerThread.start()