Added daily action to api, that logs the subj/question count

This commit is contained in:
MrFry 2020-04-01 13:13:14 +02:00
parent d37538afb3
commit 52778532dc
2 changed files with 19 additions and 2 deletions

View file

@ -38,6 +38,7 @@ const motdFile = 'public/motd'
const versionFile = 'public/version'
const passwordFile = 'data/dataEditorPasswords.json'
const dataEditsLog = 'stats/dataEdits'
const dailyDataCountFile = 'stats/dailyDataCount'
app.set('view engine', 'ejs')
app.set('views', [
@ -338,5 +339,14 @@ app.post('*', function (req, res) {
})
exports.app = app
exports.dailyAction = () => {
utils.AppendToFile(JSON.stringify({
date: new Date(),
subjectCount: data.Subjects.length,
questionCOunt: data.Subjects.reduce((acc, subj) => {
return acc + subj.Questions.length
}, 0)
}), dailyDataCountFile)
}
logger.Log('API module started', logger.GetColor('yellow'))