mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
old serverStats.js rm, minor text changes
This commit is contained in:
parent
c985fb3ee4
commit
a33bec7e71
9 changed files with 8 additions and 412 deletions
Binary file not shown.
Before Width: | Height: | Size: 252 KiB After Width: | Height: | Size: 4.2 KiB |
|
@ -1,209 +0,0 @@
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// CONFIG
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
|
|
||||||
const maxStatLength = 15
|
|
||||||
const statNameSpacing = 5
|
|
||||||
const coloredWords = {
|
|
||||||
red: ['lred'],
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
|
|
||||||
const fs = require('fs')
|
|
||||||
|
|
||||||
const dir = process.argv[2]
|
|
||||||
if (!dir) {
|
|
||||||
console.log('No params')
|
|
||||||
process.exit()
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDayIndex(offset) {
|
|
||||||
if (!offset) {
|
|
||||||
offset = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
let date = new Date()
|
|
||||||
if (offset) {
|
|
||||||
date.setDate(date.getDate() + offset)
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
date.getFullYear() +
|
|
||||||
'/' +
|
|
||||||
('0' + (date.getMonth() + 1)).slice(-2) +
|
|
||||||
'/' +
|
|
||||||
('0' + date.getDate()).slice(-2)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function C(color) {
|
|
||||||
if (color !== undefined) {
|
|
||||||
color = color.toLowerCase()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color === 'redbg') {
|
|
||||||
return '\x1b[41m'
|
|
||||||
}
|
|
||||||
if (color === 'bluebg') {
|
|
||||||
return '\x1b[44m'
|
|
||||||
}
|
|
||||||
if (color === 'green') {
|
|
||||||
return '\x1b[32m'
|
|
||||||
}
|
|
||||||
if (color === 'red') {
|
|
||||||
return '\x1b[31m'
|
|
||||||
}
|
|
||||||
if (color === 'yellow') {
|
|
||||||
return '\x1b[33m'
|
|
||||||
}
|
|
||||||
if (color === 'blue') {
|
|
||||||
return '\x1b[34m'
|
|
||||||
}
|
|
||||||
if (color === 'magenta') {
|
|
||||||
return '\x1b[35m'
|
|
||||||
}
|
|
||||||
if (color === 'cyan') {
|
|
||||||
return '\x1b[36m'
|
|
||||||
}
|
|
||||||
return '\x1b[0m'
|
|
||||||
}
|
|
||||||
|
|
||||||
function readJSON(name) {
|
|
||||||
return JSON.parse(fs.readFileSync(name, 'utf8'))
|
|
||||||
}
|
|
||||||
|
|
||||||
function tail(text, number) {
|
|
||||||
let splitedText = text.split('\n')
|
|
||||||
return splitedText.slice(Math.max(splitedText.length - number, 1)).join('\n')
|
|
||||||
}
|
|
||||||
|
|
||||||
function head(text, number) {
|
|
||||||
return text
|
|
||||||
.split('\n')
|
|
||||||
.slice(0, number)
|
|
||||||
.join('\n')
|
|
||||||
}
|
|
||||||
|
|
||||||
function readFile(name) {
|
|
||||||
return fs.readFileSync(name, 'utf8')
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLetterNTimes(letter, number) {
|
|
||||||
let res = ''
|
|
||||||
while (res.length < number) {
|
|
||||||
res += letter
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
function pCols() {
|
|
||||||
// console.log(arguments)
|
|
||||||
let maxLength = 0
|
|
||||||
Object.keys(arguments).forEach((key) => {
|
|
||||||
if (arguments[key].length > maxLength) {
|
|
||||||
maxLength = arguments[key].length
|
|
||||||
}
|
|
||||||
})
|
|
||||||
for (let i = 0; i < maxLength; i++) {
|
|
||||||
let row = []
|
|
||||||
Object.keys(arguments)
|
|
||||||
.reverse()
|
|
||||||
.forEach((key) => {
|
|
||||||
const val = arguments[key]
|
|
||||||
if (!val[i]) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const keyName = val[i].name || ''
|
|
||||||
|
|
||||||
let slicedName = keyName.slice(0, maxStatLength)
|
|
||||||
let toColor = Object.keys(coloredWords).reduce((acc, key) => {
|
|
||||||
const colorArray = coloredWords[key]
|
|
||||||
|
|
||||||
const includes = colorArray.some((colorableIdName) => {
|
|
||||||
return keyName.includes(colorableIdName)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (includes) {
|
|
||||||
return key
|
|
||||||
}
|
|
||||||
|
|
||||||
return acc
|
|
||||||
}, '')
|
|
||||||
|
|
||||||
while (slicedName.length < maxStatLength) {
|
|
||||||
slicedName = ' ' + slicedName
|
|
||||||
}
|
|
||||||
|
|
||||||
let ammount = val[i].val ? val[i].val.toString() : 0
|
|
||||||
while (ammount.length < 4) {
|
|
||||||
ammount = ammount + ' '
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toColor) {
|
|
||||||
row.push(C(toColor) + slicedName + ': ' + ammount + C())
|
|
||||||
} else {
|
|
||||||
row.push(slicedName + ' ' + ammount)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
console.log(row.join(getLetterNTimes(' ', statNameSpacing)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
const dailyStats = readJSON(`${dir}stats/vstats`)
|
|
||||||
function preProcessDailyStats(obj) {
|
|
||||||
return Object.keys(obj).map((key) => {
|
|
||||||
return { name: key, val: obj[key] }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pCols(
|
|
||||||
preProcessDailyStats(dailyStats[getDayIndex()]),
|
|
||||||
preProcessDailyStats(dailyStats[getDayIndex(-1)]),
|
|
||||||
preProcessDailyStats(dailyStats[getDayIndex(-2)])
|
|
||||||
)
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
const userIdTestSolving = readJSON(`${dir}stats/idvstats`)
|
|
||||||
function preProcessUIdTestSolving(obj) {
|
|
||||||
if (!obj) {
|
|
||||||
return [{ val: 0 }]
|
|
||||||
}
|
|
||||||
return [{ val: Object.keys(obj).length }]
|
|
||||||
}
|
|
||||||
|
|
||||||
pCols(
|
|
||||||
preProcessUIdTestSolving(userIdTestSolving[getDayIndex()]),
|
|
||||||
preProcessUIdTestSolving(userIdTestSolving[getDayIndex(-1)]),
|
|
||||||
preProcessUIdTestSolving(userIdTestSolving[getDayIndex(-2)])
|
|
||||||
)
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
const clientIdTestSolving = readJSON(`${dir}stats/uvstats`)
|
|
||||||
|
|
||||||
pCols(
|
|
||||||
preProcessUIdTestSolving(clientIdTestSolving[getDayIndex()]),
|
|
||||||
preProcessUIdTestSolving(clientIdTestSolving[getDayIndex(-1)]),
|
|
||||||
preProcessUIdTestSolving(clientIdTestSolving[getDayIndex(-2)])
|
|
||||||
)
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
const dailyDataCount = readFile(`${dir}stats/dailyDataCount`)
|
|
||||||
|
|
||||||
printLastDataCount([
|
|
||||||
JSON.parse(head(tail(dailyDataCount, 1), 1)),
|
|
||||||
JSON.parse(head(tail(dailyDataCount, 2), 1)),
|
|
||||||
JSON.parse(head(tail(dailyDataCount, 3), 1)),
|
|
||||||
])
|
|
||||||
|
|
||||||
function printLastDataCount(data) {
|
|
||||||
const res = [[], [], []]
|
|
||||||
data.forEach((dataCount, i) => {
|
|
||||||
res[i].push({ val: dataCount.userCount })
|
|
||||||
res[i].push({ val: dataCount.subjectCount })
|
|
||||||
res[i].push({ val: dataCount.questionCount })
|
|
||||||
})
|
|
||||||
|
|
||||||
pCols(...res)
|
|
||||||
}
|
|
|
@ -1,195 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ "$#" -ne "1" ]; then
|
|
||||||
echo not enough params! please specify server root directory!
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
export TERM=xterm-256color
|
|
||||||
|
|
||||||
# COLORS
|
|
||||||
NC='[0m'
|
|
||||||
# GRAY='[90m'
|
|
||||||
R='[91m'
|
|
||||||
G='[32m'
|
|
||||||
# YELLOW='[33m'
|
|
||||||
B='[94m'
|
|
||||||
P='[95m'
|
|
||||||
C='[36m'
|
|
||||||
sep="${P}----------------------------------------------------------------------------------------------------------------------------<=$NC"
|
|
||||||
|
|
||||||
pcolumns() {
|
|
||||||
mlength=35
|
|
||||||
NUM=0
|
|
||||||
l=$(echo $"$1" | wc -l)
|
|
||||||
sizeof2=$(echo $"$2" | wc -l)
|
|
||||||
sizeof3=$(echo $"$3" | wc -l)
|
|
||||||
|
|
||||||
if [ "$l" -lt "$sizeof2" ]; then
|
|
||||||
l=$(echo $"$2" | wc -l)
|
|
||||||
fi
|
|
||||||
if [ "$l" -lt "$sizeof3" ]; then
|
|
||||||
l=$(echo $"$3" | wc -l)
|
|
||||||
fi
|
|
||||||
|
|
||||||
for i in $(eval echo {0..$l}); do
|
|
||||||
line=$(echo -ne $"$1" | cut -d$'\n' -f $(($NUM + 1)))
|
|
||||||
sliced="${line:0:$mlength}"
|
|
||||||
last="${line: -3}"
|
|
||||||
size=${#sliced}
|
|
||||||
diff=$(($mlength - $size))
|
|
||||||
|
|
||||||
if [ "$sliced" == "null" ]; then
|
|
||||||
echo -en "\t"
|
|
||||||
else
|
|
||||||
echo -en "\t$sliced"
|
|
||||||
fi
|
|
||||||
if [ "$diff" -gt "0" ]; then
|
|
||||||
diff=$((diff + 2))
|
|
||||||
for j in $(eval echo {0..$diff}); do
|
|
||||||
echo -n " "
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo -en "$last"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sr=$(echo -ne $"$2" | cut -d$'\n' -f $(($NUM + 1)))
|
|
||||||
r=$"${sr:0:$mlength}"
|
|
||||||
last="${r: -3}"
|
|
||||||
size=${#r}
|
|
||||||
diff=$(($mlength - $size))
|
|
||||||
if [ "$r" == "null" ]; then
|
|
||||||
echo -ne ''
|
|
||||||
else
|
|
||||||
echo -ne "$r"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$diff" -gt "0" ]; then
|
|
||||||
diff=$((diff + 2))
|
|
||||||
for j in $(eval echo {0..$diff}); do
|
|
||||||
echo -n " "
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo -en "$last"
|
|
||||||
fi
|
|
||||||
|
|
||||||
tr=$(echo -ne $"$3" | cut -d$'\n' -f $(($NUM + 1)))
|
|
||||||
r=$"${tr:0:$mlength}"
|
|
||||||
|
|
||||||
if [ "$r" == "null" ]; then
|
|
||||||
echo ''
|
|
||||||
else
|
|
||||||
echo "$r"
|
|
||||||
fi
|
|
||||||
|
|
||||||
NUM=$((NUM + 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function jsonStats() {
|
|
||||||
dateind=$(date '+%Y-%m-%d')
|
|
||||||
a=$(cat "$1" | jq ".[\"$dateind\"]" | grep -ve '^{' | grep -ve '}$' | grep -ve '^\s*}' | sort)
|
|
||||||
ac=$(cat "$1" | jq ".[\"$dateind\"] | length")
|
|
||||||
a="\t${ac}\n${a}"
|
|
||||||
|
|
||||||
dateind=$(date -d '-1 day' '+%Y-%m-%d')
|
|
||||||
b=$(cat "$1" | jq ".[\"$dateind\"]" | grep -ve '^{' | grep -ve '}$' | grep -ve '^\s*}' | sort)
|
|
||||||
bc=$(cat "$1" | jq ".[\"$dateind\"] | length")
|
|
||||||
b="\t${bc}\n${b}"
|
|
||||||
|
|
||||||
dateind=$(date -d '-2 day' '+%Y-%m-%d')
|
|
||||||
c=$(cat "$1" | jq ".[\"$dateind\"]" | grep -ve '^{' | grep -ve '}$' | grep -ve '^\s*}' | sort)
|
|
||||||
cc=$(cat "$1" | jq ".[\"$dateind\"] | length")
|
|
||||||
c="\t${cc}\n${c}"
|
|
||||||
|
|
||||||
pcolumns $"$c" $"$b" $"$a" | sed -E \
|
|
||||||
-e "s,/getVeteranPw,${C}&${NC},g" \
|
|
||||||
-e "s,/getveteranpw,${C}&${NC},g" \
|
|
||||||
-e "s,/pwRequest,${C}&${NC},g" \
|
|
||||||
-e "s,/getpw,${C}&${NC},g" \
|
|
||||||
-e "s,/avaiblePWS,${C}&${NC},g" \
|
|
||||||
-e "s,/pwRequest,${C}&${NC},g" \
|
|
||||||
-e "s,/login,${C}&${NC},g" \
|
|
||||||
-e "s,/logout,${C}&${NC},g" \
|
|
||||||
-e "s,/manual,${G}&${NC},g" \
|
|
||||||
-e "s,/todos,${G}&${NC},g" \
|
|
||||||
-e "s,/allQuestions,${G}&${NC},g" \
|
|
||||||
-e "s,/subjectBrowser,${G}&${NC},g" \
|
|
||||||
-e "s,/repos,${G}&${NC},g" \
|
|
||||||
-e "s,/contribute,${G}&${NC},g" \
|
|
||||||
-e "s,/reops,${G}&${NC},g" \
|
|
||||||
-e "s,/feedback,${G}&${NC},g" \
|
|
||||||
-e "s,/addQuestion,${G}&${NC},g" \
|
|
||||||
-e "s,/dataCount,${G}&${NC},g" \
|
|
||||||
-e "s,/menuClick,${G}&${NC},g" \
|
|
||||||
-e "s,/ranklist,${G}&${NC},g" \
|
|
||||||
-e "s,/uploaddata,${G}&${NC},g" \
|
|
||||||
-e "s,/legacy,${G}&${NC},g" \
|
|
||||||
-e "s,/donate,${P}&${NC},g" \
|
|
||||||
-e "s,/tiszai,${P}&${NC},g" \
|
|
||||||
-e "s,/install,${P}&${NC},g" \
|
|
||||||
-e "s,/irc,${P}&${NC},g" \
|
|
||||||
-e "s,/postfeedback,${P}&${NC},g" \
|
|
||||||
-e "s,/voteTodo,${P}&${NC},g" \
|
|
||||||
-e "s,/registerscript,${P}&${NC},g" \
|
|
||||||
-e "s,/quickvote,${P}&${NC},g" \
|
|
||||||
-e "s,/servergit,${P}&${NC},g" \
|
|
||||||
-e "s,/scriptgit,${P}&${NC},g" \
|
|
||||||
-e "s,/classesgit,${P}&${NC},g" \
|
|
||||||
-e "s,/lred,${R}&${NC},g" \
|
|
||||||
-e "s,/thanks,${R}&${NC},g" \
|
|
||||||
-e "s,/isAdding,${B}&${NC},g" \
|
|
||||||
-e "s,/allqr,${B}&${NC},g" \
|
|
||||||
-e "s,/ask,${B}&${NC},g"
|
|
||||||
}
|
|
||||||
|
|
||||||
function jsonStatsLength() {
|
|
||||||
dateind=$(date '+%Y-%m-%d')
|
|
||||||
ac=$(cat "$1" | jq ".[\"$dateind\"] | length")
|
|
||||||
a="\t${ac}\n"
|
|
||||||
|
|
||||||
dateind=$(date -d '-1 day' '+%Y-%m-%d')
|
|
||||||
bc=$(cat "$1" | jq ".[\"$dateind\"] | length")
|
|
||||||
b="\t${bc}\n"
|
|
||||||
|
|
||||||
dateind=$(date -d '-2 day' '+%Y-%m-%d')
|
|
||||||
cc=$(cat "$1" | jq ".[\"$dateind\"] | length")
|
|
||||||
c="\t${cc}\n"
|
|
||||||
|
|
||||||
pcolumns $"$c" $"$b" $"$a"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo -e "${G}Site requests before / yesterday / today:$NC"
|
|
||||||
jsonStats "${1}/stats/vstats"
|
|
||||||
|
|
||||||
echo -e "$sep"
|
|
||||||
echo -e "${G}User ID test solving count before / yesterday / today:$NC"
|
|
||||||
jsonStatsLength "${1}/stats/idvstats"
|
|
||||||
|
|
||||||
echo -e "$sep"
|
|
||||||
echo -e "${G}User ID requests before / yesterday / today:$NC"
|
|
||||||
jsonStatsLength "${1}/stats/uvstats"
|
|
||||||
|
|
||||||
echo -e "$sep"
|
|
||||||
echo -e "${G}User/data count day before / day before / yesterday + new ones yesterday:$NC"
|
|
||||||
s=$(cat "${1}/stats/dailyDataCount" | tail -n 1 | jq '.subjectCount')
|
|
||||||
q=$(cat "${1}/stats/dailyDataCount" | tail -n 1 | jq '.questionCount')
|
|
||||||
u=$(cat "${1}/stats/dailyDataCount" | tail -n 1 | jq '.userCount')
|
|
||||||
|
|
||||||
st=$(cat "${1}/stats/dailyDataCount" | tail -n 2 | head -n 1 | jq '.subjectCount')
|
|
||||||
qt=$(cat "${1}/stats/dailyDataCount" | tail -n 2 | head -n 1 | jq '.questionCount')
|
|
||||||
ut=$(cat "${1}/stats/dailyDataCount" | tail -n 2 | head -n 1 | jq '.userCount')
|
|
||||||
|
|
||||||
sy=$(cat "${1}/stats/dailyDataCount" | tail -n 3 | head -n 1 | jq '.subjectCount')
|
|
||||||
qy=$(cat "${1}/stats/dailyDataCount" | tail -n 3 | head -n 1 | jq '.questionCount')
|
|
||||||
uy=$(cat "${1}/stats/dailyDataCount" | tail -n 3 | head -n 1 | jq '.userCount')
|
|
||||||
|
|
||||||
sd=$((s - st))
|
|
||||||
qd=$((q - qt))
|
|
||||||
ud=$((u - ut))
|
|
||||||
|
|
||||||
echo -e "Users:\t\t${G}${uy}${NC}\t\t\t\t\t${G}${ut}${NC}\t\t\t\t\t${G}${u}${NC}\t+${B}${ud}${NC}"
|
|
||||||
echo -e "Subjects:\t${G}${sy}${NC}\t\t\t\t\t${G}${st}${NC}\t\t\t\t\t${G}${s}${NC}\t+${B}${sd}${NC}"
|
|
||||||
echo -e "Questions:\t${G}${qy}${NC}\t\t\t\t\t${G}${qt}${NC}\t\t\t\t\t${G}${q}${NC}\t+${B}${qd}${NC}"
|
|
||||||
|
|
||||||
echo -e "$sep"
|
|
|
@ -19,8 +19,7 @@
|
||||||
"nextdir": "nextStatic/qminingPagePublic",
|
"nextdir": "nextStatic/qminingPagePublic",
|
||||||
"name": "qmining",
|
"name": "qmining",
|
||||||
"urls": [
|
"urls": [
|
||||||
"qmining.frylabs.net",
|
"qmining.frylabs.net"
|
||||||
"localhost"
|
|
||||||
],
|
],
|
||||||
"isNextJs": true
|
"isNextJs": true
|
||||||
},
|
},
|
||||||
|
@ -31,7 +30,8 @@
|
||||||
],
|
],
|
||||||
"name": "api",
|
"name": "api",
|
||||||
"urls": [
|
"urls": [
|
||||||
"api.frylabs.net"
|
"api.frylabs.net",
|
||||||
|
"localhost"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"main": {
|
"main": {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<center>
|
<center>
|
||||||
<h1>404</h1>
|
<h1>404</h1>
|
||||||
|
|
||||||
<iframe width="660" height="465" src="https://www.youtube-nocookie.com/embed/yztzob4k2xk" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
<iframe width="660" height="465" src="https://www.youtube-nocookie.com/embed/SjfspM5sDIA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||||
</center>
|
</center>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@
|
||||||
function ShowFeedback () {
|
function ShowFeedback () {
|
||||||
const form = document.getElementById('form').style.display = "none";
|
const form = document.getElementById('form').style.display = "none";
|
||||||
const feedback = document.getElementById('feedback').style.display = "block";
|
const feedback = document.getElementById('feedback').style.display = "block";
|
||||||
document.getElementById('text').innerText = 'Jelszót meglévő felhasználóktól lehet kérni!'
|
document.getElementById('text').innerText = 'Jelszót meglévő felhasználóktól lehet kérni! (nem itt)'
|
||||||
}
|
}
|
||||||
function HandleResp (resp) {
|
function HandleResp (resp) {
|
||||||
const button = document.getElementById('sendButton')
|
const button = document.getElementById('sendButton')
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit dc07c903d39003a5cc13302a9ee6e6e3e0b6ee17
|
Subproject commit 73c1cb76f096b728d156d8d50b06c80b99049cac
|
|
@ -1 +1 @@
|
||||||
Subproject commit 83ed7f3b312e0de67505601d13774bdcf2971420
|
Subproject commit a19c39c651bfbc57eb0ef2bb3371c58e1ea82cb0
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6b6b9a43d4d9c2e429adaf76c461c0304dad1133
|
Subproject commit 599ef00635c15d500dfcc1a9c226212000e74707
|
Loading…
Add table
Add a link
Reference in a new issue