From f1af3d731477421c7ee8946d0ab87a663f99a958 Mon Sep 17 00:00:00 2001 From: Dragory Date: Sun, 18 Feb 2018 20:35:07 +0200 Subject: [PATCH] legacyMigrator: add a progress indicator for log migrations --- src/legacy/legacyMigrator.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/legacy/legacyMigrator.js b/src/legacy/legacyMigrator.js index 2ccbe33..a81e9fc 100644 --- a/src/legacy/legacyMigrator.js +++ b/src/legacy/legacyMigrator.js @@ -94,7 +94,8 @@ async function migrateLogs() { const logDir = config.logDir || `${__dirname}/../../logs`; const logFiles = await readDir(logDir); - for (const logFile of logFiles) { + for (let i = 0; i < logFiles.length; i++) { + const logFile = logFiles[i]; if (! logFile.endsWith('.txt')) continue; const [rawDate, userId, threadId] = logFile.slice(0, -4).split('__'); @@ -132,6 +133,11 @@ async function migrateLogs() { created_at: date }); }); + + // Progress indicator for servers with tons of logs + if ((i + 1) % 500 === 0) { + console.log(` ${i + 1}...`); + } } }