Skip to content

Commit c40d04b

Browse files
committed
PLG: AppEvents not clearing in DBCLNP
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
1 parent ea8e264 commit c40d04b

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

front/plugins/db_cleanup/script.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,15 @@ def cleanup_database(
142142
# AppEvents
143143
histCount = get_setting_value("WORKFLOWS_AppEvents_hist")
144144
mylog("verbose", [f"[{pluginName}] Trim AppEvents to less than {histCount}"])
145-
delete_query = f"""DELETE FROM AppEvents
146-
WHERE "Index" NOT IN (
147-
SELECT "Index"
148-
FROM (
149-
SELECT "Index",
150-
ROW_NUMBER() OVER(PARTITION BY "index" ORDER BY dateTimeCreated DESC) AS row_num
151-
FROM AppEvents
152-
) AS ranked_objects
153-
WHERE row_num <= {histCount}
154-
);"""
145+
delete_query = f"""
146+
DELETE FROM AppEvents
147+
WHERE "Index" < (
148+
SELECT "Index"
149+
FROM AppEvents
150+
ORDER BY dateTimeCreated DESC
151+
LIMIT 1 OFFSET {histCount}
152+
);
153+
"""
155154
cursor.execute(delete_query)
156155
mylog("verbose", [f"[{pluginName}] AppEvents deleted rows: {cursor.rowcount}"])
157156

0 commit comments

Comments
 (0)