From 01764754b06140eb20ac152b46dab9d22f4d168d Mon Sep 17 00:00:00 2001 From: mrfry Date: Thu, 18 Mar 2021 18:32:13 +0100 Subject: [PATCH] logging subj/question count on server start --- src/utils/actions.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/utils/actions.ts b/src/utils/actions.ts index 9a6704a..2c08e89 100755 --- a/src/utils/actions.ts +++ b/src/utils/actions.ts @@ -359,7 +359,7 @@ export function loadJSON( dataFiles: Array, dataDir: string ): Array { - return dataFiles.reduce((acc, dataFile, index) => { + const res: Array = dataFiles.reduce((acc, dataFile, index) => { const dataPath = dataDir + dataFile.path if (!utils.FileExists(dataPath)) { @@ -382,6 +382,21 @@ export function loadJSON( } return acc }, []) + + let subjCount = 0 + let questionCount = 0 + res.forEach((qdb) => { + subjCount += qdb.data.length + qdb.data.forEach((subj) => { + questionCount += subj.Questions.length + }) + }) + logger.Log( + `Loaded ${subjCount} subjects with ${questionCount} questions from ${res.length} question db-s`, + logger.GetColor('green') + ) + + return res } export function writeData(data: Array, path: string): void {