Update cleanup.js

This commit is contained in:
Aleksandr Statciuk 2022-02-13 07:16:15 +03:00
parent d00e2e5e38
commit 6a96f23040
1 changed files with 3 additions and 3 deletions

View File

@ -9,12 +9,12 @@ async function main() {
let removed = 0
const buffer = {}
for (const stream of streams) {
const duplicate = buffer[stream.channel_id]
if (duplicate && ['offline', 'timeout'].includes(stream.status.code)) {
const duplicate = buffer[stream.channel]
if (duplicate && !stream.is_online) {
await db.streams.remove({ _id: stream._id })
removed++
} else {
buffer[stream.channel_id] = stream
buffer[stream.channel] = stream
}
}
db.streams.compact()