logging subj/question count on server start

This commit is contained in:
mrfry 2021-03-18 18:32:13 +01:00
parent 473b6d1b21
commit 01764754b0

View file

@ -359,7 +359,7 @@ export function loadJSON(
dataFiles: Array<DataFile>,
dataDir: string
): Array<QuestionDb> {
return dataFiles.reduce((acc, dataFile, index) => {
const res: Array<QuestionDb> = 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<Subject>, path: string): void {