package updates, server stats script update

This commit is contained in:
mrfry 2021-11-22 20:14:45 +01:00
parent c13035a8df
commit 1a646db611
5 changed files with 83 additions and 69 deletions

View file

@ -83,19 +83,29 @@ const filterFromDailyStats = [
const fs = require('fs') // eslint-disable-line
const dir = process.argv[2]
const startDay = !isNaN(parseInt(process.argv[3])) && parseInt(process.argv[3]) > 0 ? 0 : parseInt(process.argv[3])
if (!dir) {
console.log('No params')
process.exit()
}
function getDayIndex(offset) {
let os = offset
if (!offset) {
offset = 0
os = 0
}
if (!isNaN(startDay)) {
if (!offset) {
os = startDay
} else {
os = startDay + offset
}
}
const date = new Date()
if (offset) {
date.setDate(date.getDate() + offset)
if (os) {
date.setDate(date.getDate() + os)
}
return (
date.getFullYear() +
@ -172,7 +182,11 @@ function countLinesMatching(text, toMatch) {
}
function getDayName(day) {
switch (day) {
let d = day
if (!isNaN(startDay)) {
d += startDay
}
switch (d) {
case 0:
case undefined:
return 'Today'
@ -181,7 +195,9 @@ function getDayName(day) {
case -2:
return 'Before yesterday'
default:
return `Day ${day.toString()}`
const now = new Date()
now.setDate(now.getDate() + d);
return now.toDateString()
}
}
@ -252,7 +268,7 @@ function pCols(cols, rowTitles, colorNames, firstRowColor) {
slicedName = slicedName + sep
}
let ammount = val[i].val ? val[i].val.toString() : ''
let ammount = val[i].val ? val[i].val.toLocaleString() : ''
while (ammount.length < 5) {
ammount = ammount + ' '
}
@ -432,9 +448,9 @@ try {
return [getDayName(-x)]
})
data.forEach((dataCount, i) => {
res[i].push(dataCount.userCount.toString())
res[i].push(dataCount.subjectCount.toString())
res[i].push(dataCount.questionCount.toString())
res[i].push(dataCount.userCount.toLocaleString())
res[i].push(dataCount.subjectCount.toLocaleString())
res[i].push(dataCount.questionCount.toLocaleString())
})
pCols(res, ['', 'Users', 'Subjects', 'Questions'], false, 'green')
@ -456,8 +472,8 @@ try {
}
return [
getDayName(day),
countLinesMatching(log, '?install').toString(),
countLinesMatching(log, '?up').toString(),
countLinesMatching(log, '?install').toLocaleString(),
countLinesMatching(log, '?up').toLocaleString(),
]
}