From d99dfa87963d55075e12cdea88b99028563065c3 Mon Sep 17 00:00:00 2001 From: Tibor Arpas Date: Tue, 30 May 2023 13:42:33 +0200 Subject: [PATCH] Improve/fix cleanup. --- testmon/db.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/testmon/db.py b/testmon/db.py index c7ee2d9..6cbe1bd 100644 --- a/testmon/db.py +++ b/testmon/db.py @@ -91,14 +91,14 @@ def finish_execution(self, exec_id, duration=None, select=True): self.update_saving_stats(exec_id, select) self.fetch_or_create_file_fp.cache_clear() with self.con as con: - con.execute( - """ - DELETE FROM file_fp + self.vacuum_file_fp(con) + + def vacuum_file_fp(self, con): + con.execute( + """ DELETE FROM file_fp WHERE id NOT IN ( - SELECT DISTINCT fingerprint_id FROM test_execution_file_fp - ) - """ - ) + SELECT DISTINCT fingerprint_id FROM test_execution_file_fp) """ + ) def fetch_current_run_stats(self, exec_id): with self.con as con: @@ -276,10 +276,6 @@ def insert_test_file_fps(self, tests_deps_n_outcomes, exec_id=None): test_execution_file_fps, ) self.fetch_or_create_file_fp.cache_clear() - cursor.execute( - "DELETE FROM file_fp WHERE " - " id NOT IN (select fingerprint_id from test_execution_file_fp)" - ) self.insert_into_suite_files_fshas(con, exec_id, files_fshas) def insert_into_suite_files_fshas(self, con, exec_id, files_fshas):