From 712650e65c5897cbad0e2ceab224b2bfc446d296 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 12 Dec 2021 08:09:01 +0300 Subject: [PATCH] Update update-database.js --- scripts/commands/update-database.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/commands/update-database.js b/scripts/commands/update-database.js index 4dad7658f3..459ab9ac22 100644 --- a/scripts/commands/update-database.js +++ b/scripts/commands/update-database.js @@ -15,6 +15,7 @@ const EPG_CODES_FILEPATH = process.env.EPG_CODES_FILEPATH || 'scripts/data/codes async function main() { await setUp() await loadDatabase() + await removeDuplicates() await loadCheckResults() await findStreamOrigins() await updateStreams() @@ -31,6 +32,16 @@ async function loadDatabase() { logger.info(`Found ${streams.length} streams`) } +async function removeDuplicates() { + logger.info('Removing duplicates...') + + const before = streams.length + streams = _.uniqBy(streams, 'id') + const after = streams.length + + logger.info(`Removed ${before - after} links`) +} + async function loadCheckResults() { logger.info('Loading check results from logs/...')