mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
added id and idv stats file to files
This commit is contained in:
parent
f66f83edc4
commit
5106614088
2 changed files with 16 additions and 6 deletions
|
@ -248,6 +248,16 @@ export const files = {
|
||||||
defaultValue: JSON.stringify({}),
|
defaultValue: JSON.stringify({}),
|
||||||
description: 'json of visits per user by day',
|
description: 'json of visits per user by day',
|
||||||
},
|
},
|
||||||
|
idstatsFile: {
|
||||||
|
path: './stats/idstats',
|
||||||
|
defaultValue: JSON.stringify({}),
|
||||||
|
description: 'json of various statistics per user id',
|
||||||
|
},
|
||||||
|
idvstatsFile: {
|
||||||
|
path: './stats/idvstats',
|
||||||
|
defaultValue: JSON.stringify({}),
|
||||||
|
description: 'json of various statistics per user id per day',
|
||||||
|
},
|
||||||
nologFile: {
|
nologFile: {
|
||||||
path: './data/nolog',
|
path: './data/nolog',
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
|
|
|
@ -25,8 +25,8 @@ export default {
|
||||||
|
|
||||||
import utils from '../utils/utils'
|
import utils from '../utils/utils'
|
||||||
import logger from '../utils/logger'
|
import logger from '../utils/logger'
|
||||||
const idStatFile = 'stats/idstats'
|
|
||||||
const idVStatFile = 'stats/idvstats'
|
import { paths } from './files'
|
||||||
|
|
||||||
const writeInterval = 1
|
const writeInterval = 1
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ let writes = 0
|
||||||
|
|
||||||
function Load(): void {
|
function Load(): void {
|
||||||
try {
|
try {
|
||||||
idStatsData = utils.ReadJSON(idStatFile)
|
idStatsData = utils.ReadJSON(paths.idstatsFile)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.Log(
|
logger.Log(
|
||||||
'Error at loading id logs! (@ first run its normal)',
|
'Error at loading id logs! (@ first run its normal)',
|
||||||
|
@ -46,7 +46,7 @@ function Load(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const prevVData = utils.ReadFile(idVStatFile)
|
const prevVData = utils.ReadFile(paths.idvstatsFile)
|
||||||
idvStatsData = JSON.parse(prevVData)
|
idvStatsData = JSON.parse(prevVData)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.Log(
|
logger.Log(
|
||||||
|
@ -129,14 +129,14 @@ function Save() {
|
||||||
writes++
|
writes++
|
||||||
if (writes === writeInterval) {
|
if (writes === writeInterval) {
|
||||||
try {
|
try {
|
||||||
utils.WriteFile(JSON.stringify(idStatsData), idStatFile)
|
utils.WriteFile(JSON.stringify(idStatsData), paths.idstatsFile)
|
||||||
// Log("Stats wrote.");
|
// Log("Stats wrote.");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.Log('Error at writing logs!', logger.GetColor('redbg'))
|
logger.Log('Error at writing logs!', logger.GetColor('redbg'))
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
utils.WriteFile(JSON.stringify(idvStatsData), idVStatFile)
|
utils.WriteFile(JSON.stringify(idvStatsData), paths.idvstatsFile)
|
||||||
// Log("Stats wrote.");
|
// Log("Stats wrote.");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.Log('Error at writing visit logs!', logger.GetColor('redbg'))
|
logger.Log('Error at writing visit logs!', logger.GetColor('redbg'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue