Update save-results.js

This commit is contained in:
Aleksandr Statciuk 2022-01-30 20:54:09 +03:00
parent d2e43e46fe
commit 1b63609b7d
4 changed files with 11 additions and 29 deletions

View file

@ -4,8 +4,6 @@ const _ = require('lodash')
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
async function main() {
const errorsLog = `${LOGS_DIR}/errors.log`
await file.create(errorsLog)
await db.queue.load()
await db.programs.load()
await db.programs.reset()
@ -34,15 +32,8 @@ async function main() {
await db.queue.update(
{ _id: result.channel._id },
{ $set: { programCount: result.programs.length } }
{ $set: { programCount: result.programs.length, error: result.error } }
)
if (result.error) {
await file.append(
errorsLog,
JSON.stringify({ ...result.channel, date: result.date, error: result.error }) + '\n'
)
}
}
}