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

Source Code for Module commands.vacuum_graphs

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