feat(backend): only log pruned queue items / db freed space if > 0

This commit is contained in:
psychedelicious 2023-12-01 09:26:44 +11:00 committed by Kent Keirsey
parent 0228aba06f
commit 3f0e0af177
2 changed files with 4 additions and 2 deletions

View File

@ -42,7 +42,8 @@ class SqliteSessionQueue(SessionQueueBase):
self._set_in_progress_to_canceled()
prune_result = self.prune(DEFAULT_QUEUE_ID)
local_handler.register(event_name=EventServiceBase.queue_event, _func=self._on_session_event)
self.__invoker.services.logger.info(f"Pruned {prune_result.deleted} finished queue items")
if prune_result.deleted > 0:
self.__invoker.services.logger.info(f"Pruned {prune_result.deleted} finished queue items")
def __init__(self, db: SqliteDatabase) -> None:
super().__init__()

View File

@ -41,7 +41,8 @@ class SqliteDatabase:
self.conn.commit()
final_db_size = Path(self.db_path).stat().st_size
freed_space_in_mb = round((initial_db_size - final_db_size) / 1024 / 1024, 2)
self._logger.info(f"Cleaned database (freed {freed_space_in_mb}MB)")
if freed_space_in_mb > 0:
self._logger.info(f"Cleaned database (freed {freed_space_in_mb}MB)")
except Exception as e:
self._logger.error(f"Error cleaning database: {e}")
raise e