From 30581d1b507015c7634f0dc27de3c7d40dec542f Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 24 Aug 2022 03:14:25 +0300 Subject: [PATCH] Update update.js --- scripts/commands/database/update.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/commands/database/update.js b/scripts/commands/database/update.js index 99c55c6669..da1f616b03 100644 --- a/scripts/commands/database/update.js +++ b/scripts/commands/database/update.js @@ -1,5 +1,8 @@ const { db, store, parser, file, logger } = require('../../core') const _ = require('lodash') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +dayjs.extend(utc) const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs/cluster/load' @@ -19,6 +22,7 @@ async function updateStreams(items = [], results = {}, origins = {}) { let buffer = {} let updated = 0 let removed = 0 + const now = dayjs.utc().format() for (const item of items) { const stream = store.create(item) const result = results[item._id] @@ -46,6 +50,7 @@ async function updateStreams(items = [], results = {}, origins = {}) { await db.streams.remove({ _id: stream.get('_id') }) removed++ } else if (stream.changed) { + stream.set('updated_at', { updated_at: now }) await db.streams.update({ _id: stream.get('_id') }, stream.data()) buffer[stream.get('url')] = true updated++