Ranklist logging

This commit is contained in:
mrfry 2020-10-23 12:01:11 +02:00
parent 13a18c3fd8
commit c90c879fc0
4 changed files with 68 additions and 71 deletions

View file

@ -16,6 +16,6 @@ module.exports = {
eqeqeq: ['warn', 'smart'],
'no-unused-vars': 'warn',
'no-prototype-builtins': 'off',
'id-length': ['warn', { exceptions: ['i', 'j', 't', 'Q', 'A', 'C', 'q'] }],
'id-length': ['warn', { exceptions: ['i', 'j', 't', 'Q', 'A', 'C', 'q', 'a', 'b'] }],
},
}

View file

@ -18,80 +18,75 @@ P=''
C=''
sep="${P}----------------------------------------------------------------------------------------------------------------------------<=$NC"
pcolumns () {
mlength=35
NUM=0;
l=$(echo $"$1" | wc -l)
sizeof2=$(echo $"$2" | wc -l)
sizeof3=$(echo $"$3" | wc -l)
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
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))
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
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
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
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
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
NUM=$((NUM + 1))
done
}
function jsonStats () {
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")
@ -125,7 +120,7 @@ function jsonStats () {
-e "s,/addQuestion,${G}&${NC},g" \
-e "s,/dataCount,${G}&${NC},g" \
-e "s,/menuClick,${G}&${NC},g" \
-e "s,/allqr,${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" \
@ -140,10 +135,11 @@ function jsonStats () {
-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 () {
function jsonStatsLength() {
dateind=$(date '+%Y/%m/%d')
ac=$(cat "$1" | jq ".[\"$dateind\"] | length")
a="\t${ac}\n"
@ -184,9 +180,9 @@ 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))
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}"

View file

@ -163,6 +163,7 @@ function GetApp() {
// -------------------------------------------------------------
app.get('/ranklist', (req, res) => {
logger.LogReq(req)
const user = req.session.user
const data = utils.ReadJSON(idStatFile)

@ -1 +1 @@
Subproject commit 5385ef67b6655ea87009761cc5c2b5daebdfa1e0
Subproject commit ebad81a75ec4bb43d918136adf1724d25f3f91a9