Fixed bug with 24h counter failing on new db
This commit is contained in:
@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user