fix batch delete query does not use index

This commit is contained in:
Hongbo Wu
2024-06-14 12:21:20 +08:00
parent aea1650626
commit c0947ddd48
2 changed files with 1 additions and 25 deletions

View File

@ -970,10 +970,10 @@ export const emptyTrashResolver = authorized<
})
await batchDelete({
state: LibraryItemState.Deleted,
user: {
id: uid,
},
state: LibraryItemState.Deleted,
})
return {

View File

@ -1392,30 +1392,6 @@ export const batchDelete = async (criteria: FindOptionsWhere<LibraryItem>) => {
return authTrx(async (t) => t.query(sql))
}
export const batchDeleteAllTrash = async () => {
const sql = `
DO $$
DECLARE
user_record RECORD;
user_cursor CURSOR FOR SELECT id FROM omnivore.user WHERE status = 'ACTIVE'; -- Adjust the condition as needed
BEGIN
OPEN user_cursor;
LOOP
FETCH NEXT FROM user_cursor INTO user_record;
EXIT WHEN NOT FOUND;
DELETE FROM omnivore.library_item WHERE user_id = user_record.id AND state = 'DELETED' AND deleted_at < '2023-01-01';
RETURN NEXT;
END LOOP;
CLOSE user_cursor;
END $$;`
return authTrx(async (t) => t.query(sql))
}
export const findLibraryItemIdsByLabelId = async (
labelId: string,
userId: string