Package commands :: Module vacuum_graphs
[hide private]
[frames] | no frames]

Source Code for Module commands.vacuum_graphs

 1  import click 
 2  import time 
 3  from sqlalchemy import and_, or_ 
 4  from coprs import db 
 5  from coprs import models 
6 7 @click.command() 8 -def vacuum_graphs():
9 """ 10 Removes old cached graph data that is no longer used. 11 """ 12 curr_time = int(time.time()) 13 models.BuildsStatistics.query.filter(or_( 14 and_(models.BuildsStatistics.time < curr_time - 91 * 86400, 15 models.BuildsStatistics.stat_type == '24h'), 16 and_(models.BuildsStatistics.time < curr_time - 87000, 17 models.BuildsStatistics.stat_type == '30min'), 18 and_(models.BuildsStatistics.time < curr_time - 87000, 19 models.BuildsStatistics.stat_type == '10min') 20 )).delete() 21 db.session.commit()
22