legacyMigrator: add a progress indicator for log migrations

master
Dragory 2018-02-18 20:35:07 +02:00
parent a668818421
commit f1af3d7314
1 changed files with 7 additions and 1 deletions

View File

@ -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}...`);
}
}
}