From 0c1b38b7e214a250dbe0995d902b46631fbcce4b Mon Sep 17 00:00:00 2001 From: ale Date: Mon, 14 Oct 2024 20:16:45 +0200 Subject: [PATCH] taskdeletedup --- lib/taskdeletedup.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/taskdeletedup.js b/lib/taskdeletedup.js index 4d99abb..eeac679 100644 --- a/lib/taskdeletedup.js +++ b/lib/taskdeletedup.js @@ -26,17 +26,17 @@ module.exports = client => { search_after: lastsort } }) - for (const status of result.hits.hits) { - if (last && status._source && last.instance === status._source.instance) { - await client.delete({ index: index, id: status._id }) + for (const instance of result.hits.hits) { + if (last && instance._source && last.instance === instance._source.instance) { + await client.delete({ index: index, id: instance._id }) count.deleted++ - console.log('deleted ' + status._id + ': ' + status._source.instance) + console.log('deleted ' + instance._id + ': ' + instance._source.instance) } else { - last = status._source + last = instance._source } - if (status._id === result.hits.hits[result.hits.hits.length - 1]._id) { - lastsort = status.sort + if (instance._id === result.hits.hits[result.hits.hits.length - 1]._id) { + lastsort = instance.sort } } count.total += result.hits.hits.length @@ -44,7 +44,7 @@ module.exports = client => { break } } while (result.hits && result.hits.hits && result.hits.hits.length > 0) - return console.log('Index: ' + index + ' - Total: ' + count.total + ' - Deleted: ' + count.deleted) + return console.log('Index: ' + constant.index + ' - Total: ' + count.total + ' - Deleted: ' + count.deleted) }, job = schedule.scheduleJob('0 ' + constant.taskdeletedup + ' * * *', async () => { await deleteDup()