Merge "Execute vacuum command after cleaning up DB"
This commit is contained in:
@@ -192,6 +192,7 @@ class BuildCache:
|
||||
|
||||
# clean builds that are older than 1 day
|
||||
self.clean()
|
||||
self.vacuum()
|
||||
|
||||
rows = self.fetch_data()
|
||||
if rows:
|
||||
@@ -223,6 +224,10 @@ class BuildCache:
|
||||
def add(self, uid):
|
||||
self.builds[uid] = int(datetime.datetime.now().timestamp())
|
||||
|
||||
def vacuum(self):
|
||||
self.cursor.execute("vacuum")
|
||||
self.connection.commit()
|
||||
|
||||
def clean(self):
|
||||
# Remove old builds
|
||||
yesterday = datetime.datetime.now() - datetime.timedelta(days=1)
|
||||
|
||||
@@ -652,7 +652,7 @@ class TestBuildCache(base.TestCase):
|
||||
mock_execute = mock_connect.return_value.cursor.return_value.execute
|
||||
mock_execute.assert_called()
|
||||
self.assertEqual('SELECT uid, timestamp FROM logscraper',
|
||||
mock_execute.call_args_list[2].args[0])
|
||||
mock_execute.call_args_list[3].args[0])
|
||||
|
||||
def test_clean(self):
|
||||
# add old data
|
||||
|
||||
Reference in New Issue
Block a user