From 37e7d87a53e0f5a2b95057772e4909780faad332 Mon Sep 17 00:00:00 2001 From: John Davis Date: Wed, 8 May 2024 10:24:47 -0400 Subject: [PATCH] Check for empty batch earlier --- lib/galaxy/model/scripts/history_table_pruner.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/model/scripts/history_table_pruner.py b/lib/galaxy/model/scripts/history_table_pruner.py index 329d3f8bb7d..217468dfdb3 100644 --- a/lib/galaxy/model/scripts/history_table_pruner.py +++ b/lib/galaxy/model/scripts/history_table_pruner.py @@ -63,14 +63,19 @@ class HistoryTablePruner: return today.replace(month=today.month - 1) def _run_batch(self, low, high): + empty_batch_msg = f"No histories to delete in the id range {low}-{high}" self._mark_histories_as_deleted_and_purged(low, high) histories = self._get_histories(low, high) + if not histories: + logging.info(empty_batch_msg) + return + exclude = self._get_histories_to_exclude(low, high) # Calculate set of histories to delete. to_delete = set(histories) - exclude if not to_delete: - logging.info(f"No histories to delete in the id range {low}-{high}") + logging.info(empty_batch_msg) return self._create_tmp_table()