From b7b04384c26c63ce34eb64e49e8a3ab69244bec5 Mon Sep 17 00:00:00 2001 From: Taylor Talkington Date: Fri, 4 Jun 2021 04:25:10 -0400 Subject: [PATCH] Remove stats data over 30 days old --- scripts/update_data.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/update_data.py b/scripts/update_data.py index 5b3d0582a..435cfb172 100644 --- a/scripts/update_data.py +++ b/scripts/update_data.py @@ -36,6 +36,8 @@ def update_stats(self): # remove the current date if it exists stats[pid]['history'] = [x for x in stats[pid]['history'] if x['date']!=dt.strftime('%Y-%m-%d')] + # remove old history + stats[pid]['history'] = [x for x in stats[pid]['history'] if (datetime.datetime.now()-datetime.datetime.strptime(x['date'], '%Y-%m-%d')).days <= 30] stats[pid]['history'].append({ 'date': dt.strftime('%Y-%m-%d'), 'total': stats30['instances'],