~sircmpwn/hnstats

759642225a423ee1c8332b0c9cee8f249de8489e — Drew DeVault 6 years ago ad49a38
Add cleanup script
1 files changed, 16 insertions(+), 0 deletions(-)

A clean.py
A clean.py => clean.py +16 -0
@@ 0,0 1,16 @@
#!/usr/bin/env python3
from datetime import datetime, timedelta
from .update import db, ArticleSample

cutoff = datetime.utcnow() - timedelta(days=15)

ArticleSample.query\
    .filter(ArticleSample.rank > 50)\
    .filter(ArticleSample.sample_time < cutoff)\
    .delete()

cutoff = datetime.utcnow() - timedelta(days=90)

records = ArticleSample.query\
    .filter(ArticleSample.sample_time < cutoff)\
    .delete()