File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments