fix: export all items job stuck

This commit is contained in:
Hongbo Wu
2024-04-22 19:45:25 +08:00
parent 201a5817ef
commit a77ade0890
2 changed files with 10 additions and 6 deletions

View File

@ -50,9 +50,9 @@ export const exportAllItems = async (jobData: ExportAllItemsJobData) => {
const maxItems = 100
const limit = 10
let offset = 0
let exported = 0
// get max 100 most recent items from the database
while (offset < maxItems) {
for (let offset = 0; offset < maxItems; offset += limit) {
const libraryItems = await findRecentLibraryItems(userId, limit, offset)
if (libraryItems.length === 0) {
logger.info('no library items found', {
@ -92,17 +92,17 @@ export const exportAllItems = async (jobData: ExportAllItemsJobData) => {
updated,
})
offset += libraryItems.length
exported += libraryItems.length
logger.info('exported items', {
...jobData,
offset,
exported,
})
}
logger.info('exported all items', {
...jobData,
offset,
exported,
})
// clear task name in integration

View File

@ -1216,7 +1216,11 @@ export const batchUpdateLibraryItems = async (
await authTrx(
async (tx) =>
getQueryBuilder(userId, tx).update(LibraryItem).set(values).execute(),
getQueryBuilder(userId, tx)
.take(searchArgs.size)
.update(LibraryItem)
.set(values)
.execute(),
undefined,
userId
)