Delete old chart entries

This commit is contained in:
shortcutme 2018-12-04 14:16:06 +01:00
parent e0c56c6342
commit 3d1d5c1151
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -119,5 +119,15 @@ class ChartDb(Db):
time.sleep(0.1)
if num_archived == 0:
break
# Only keep 6 month of global stats
self.execute(
"DELETE FROM data WHERE site_id IS NULL AND date_added < :date_added_limit",
{"date_added_limit": time.time() - 60 * 60 * 24 * 30 * 6 }
)
# Only keep 1 month of site stats
self.execute(
"DELETE FROM data WHERE site_id IS NOT NULL AND date_added < :date_added_limit",
{"date_added_limit": time.time() - 60 * 60 * 24 * 30 }
)
if week_back > 1:
self.execute("VACUUM")