taskdeletedup
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
ale 2024-10-14 20:16:45 +02:00
parent 952a0dc226
commit 0c1b38b7e2

View File

@ -26,17 +26,17 @@ module.exports = client => {
search_after: lastsort search_after: lastsort
} }
}) })
for (const status of result.hits.hits) { for (const instance of result.hits.hits) {
if (last && status._source && last.instance === status._source.instance) { if (last && instance._source && last.instance === instance._source.instance) {
await client.delete({ index: index, id: status._id }) await client.delete({ index: index, id: instance._id })
count.deleted++ count.deleted++
console.log('deleted ' + status._id + ': ' + status._source.instance) console.log('deleted ' + instance._id + ': ' + instance._source.instance)
} }
else { else {
last = status._source last = instance._source
} }
if (status._id === result.hits.hits[result.hits.hits.length - 1]._id) { if (instance._id === result.hits.hits[result.hits.hits.length - 1]._id) {
lastsort = status.sort lastsort = instance.sort
} }
} }
count.total += result.hits.hits.length count.total += result.hits.hits.length
@ -44,7 +44,7 @@ module.exports = client => {
break break
} }
} while (result.hits && result.hits.hits && result.hits.hits.length > 0) } 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 () => { job = schedule.scheduleJob('0 ' + constant.taskdeletedup + ' * * *', async () => {
await deleteDup() await deleteDup()