From c40d04b2c46f8ac2cad218439d3e65895a8e56d6 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Fri, 10 Apr 2026 22:10:00 +1000 Subject: [PATCH] PLG: AppEvents not clearing in DBCLNP Signed-off-by: jokob-sk --- front/plugins/db_cleanup/script.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/front/plugins/db_cleanup/script.py b/front/plugins/db_cleanup/script.py index a6966e2c..844a28c1 100755 --- a/front/plugins/db_cleanup/script.py +++ b/front/plugins/db_cleanup/script.py @@ -142,16 +142,15 @@ def cleanup_database( # AppEvents histCount = get_setting_value("WORKFLOWS_AppEvents_hist") mylog("verbose", [f"[{pluginName}] Trim AppEvents to less than {histCount}"]) - delete_query = f"""DELETE FROM AppEvents - WHERE "Index" NOT IN ( - SELECT "Index" - FROM ( - SELECT "Index", - ROW_NUMBER() OVER(PARTITION BY "index" ORDER BY dateTimeCreated DESC) AS row_num - FROM AppEvents - ) AS ranked_objects - WHERE row_num <= {histCount} - );""" + delete_query = f""" + DELETE FROM AppEvents + WHERE "Index" < ( + SELECT "Index" + FROM AppEvents + ORDER BY dateTimeCreated DESC + LIMIT 1 OFFSET {histCount} + ); + """ cursor.execute(delete_query) mylog("verbose", [f"[{pluginName}] AppEvents deleted rows: {cursor.rowcount}"])