mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
User stat logging excludes
This commit is contained in:
parent
be81235b53
commit
bd1ebea800
2 changed files with 9 additions and 7 deletions
0
src/tests/oldQuestionRemoving.test.ts
Normal file
0
src/tests/oldQuestionRemoving.test.ts
Normal file
|
@ -41,11 +41,6 @@ const logFileName = 'log'
|
|||
const writeInterval = 10
|
||||
const debugLevel = parseInt(process.env.NS_LOGLEVEL) || 0
|
||||
|
||||
// let vdata = {} // visit data
|
||||
// let dvData = {} // visit data, but daily
|
||||
// let uData = {} // visit data, but per user
|
||||
// let udvData = {} // visit data, but per user and daily
|
||||
|
||||
let vData = {} // visit data
|
||||
let dvData = {} // visit data, but daily
|
||||
let uvData = {} // visit data, but per user
|
||||
|
@ -238,12 +233,19 @@ function LogStat(url: string, hostname: string, userId: number | string): void {
|
|||
|
||||
url = hostname + url.split('?')[0]
|
||||
Inc(url)
|
||||
AddVisitStat(url)
|
||||
if (shouldAddUserStat(url)) {
|
||||
AddUserIdStat(userId.toString())
|
||||
IncUserStat(userId.toString())
|
||||
AddVisitStat(url)
|
||||
}
|
||||
Save()
|
||||
}
|
||||
|
||||
const userStatExcludes = ['stable.user.js', 'infos', 'hasNewMsg']
|
||||
function shouldAddUserStat(url: string) {
|
||||
return !userStatExcludes.some((x) => url.includes(x))
|
||||
}
|
||||
|
||||
function IncUserStat(userId: string) {
|
||||
try {
|
||||
if (uvData[userId] === undefined) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue