clean build_reservations table
This commit is contained in:
parent
54d6630345
commit
ba54425854
3 changed files with 25 additions and 2 deletions
|
|
@ -19,6 +19,18 @@ def clean_sessions(cursor, vacuum):
|
|||
cursor.execute("VACUUM ANALYZE sessions")
|
||||
|
||||
|
||||
def clean_reservations(cursor, vacuum):
|
||||
q = " FROM build_reservations WHERE create_time < now() - '1 day'::interval"
|
||||
if options.verbose:
|
||||
cursor.execute("SELECT COUNT(*) " + q)
|
||||
rows = cursor.fetchall()[0][0]
|
||||
print("Deleting %d build reservations" % rows)
|
||||
|
||||
cursor.execute("DELETE " + q)
|
||||
if vacuum:
|
||||
cursor.execute("VACUUM ANALYZE build_reservations")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
global options
|
||||
parser = OptionParser("%prog cleans koji database")
|
||||
|
|
@ -72,4 +84,5 @@ if __name__ == "__main__":
|
|||
cursor = conn.cursor()
|
||||
|
||||
clean_sessions(cursor, options.vacuum)
|
||||
clean_reservations(cursor, options.vacuum)
|
||||
conn.commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue