diff --git a/front/plugins/db_cleanup/script.py b/front/plugins/db_cleanup/script.py index cae8ec28..dd6b67b5 100755 --- a/front/plugins/db_cleanup/script.py +++ b/front/plugins/db_cleanup/script.py @@ -130,15 +130,11 @@ def cleanup_database( histCount = get_setting_value("DBCLNP_NOTIFI_HIST") mylog("verbose", f"[{pluginName}] Notifications: Trim to {histCount}") delete_query = f"""DELETE FROM Notifications - WHERE "Index" NOT IN ( - SELECT "Index" - FROM ( - SELECT "Index", - ROW_NUMBER() OVER(PARTITION BY "index" ORDER BY dateTimeCreated DESC) AS row_num - FROM Notifications - ) AS ranked_objects - WHERE row_num <= {histCount} - );""" + WHERE "Index" NOT IN ( + SELECT "Index" FROM Notifications + ORDER BY dateTimeCreated DESC + LIMIT {histCount} + );""" cursor.execute(delete_query) mylog("verbose", [f"[{pluginName}] Notifications deleted rows: {cursor.rowcount}"])