mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Modified stuff for easyer testing, logging questiondb count in daily stats
This commit is contained in:
parent
d7b5ad8160
commit
cc19b5424b
8 changed files with 11 additions and 40 deletions
|
@ -1 +0,0 @@
|
||||||
[]
|
|
|
@ -13,6 +13,9 @@ export const testUser = {
|
||||||
avaiblePWRequests: 645,
|
avaiblePWRequests: 645,
|
||||||
pwRequestCount: 19,
|
pwRequestCount: 19,
|
||||||
created: new Date(),
|
created: new Date(),
|
||||||
|
pw: 'secret',
|
||||||
|
loginCount: 3,
|
||||||
|
createdBy: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderLogin(req, res, jsonResponse) {
|
function renderLogin(req, res, jsonResponse) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ function ExportDailyDataCount(questionDbs, userDB) {
|
||||||
date: utils.GetDateString(),
|
date: utils.GetDateString(),
|
||||||
subjectCount: getSubjCount(questionDbs),
|
subjectCount: getSubjCount(questionDbs),
|
||||||
questionCount: getQuestionCount(questionDbs),
|
questionCount: getQuestionCount(questionDbs),
|
||||||
|
questionDbsCount: questionDbs.length,
|
||||||
userCount: dbtools.TableInfo(userDB, 'users').dataCount,
|
userCount: dbtools.TableInfo(userDB, 'users').dataCount,
|
||||||
}),
|
}),
|
||||||
dailyDataCountFile
|
dailyDataCountFile
|
||||||
|
|
|
@ -48,7 +48,6 @@ export interface RecievedData {
|
||||||
subj: string
|
subj: string
|
||||||
id: string
|
id: string
|
||||||
version: string
|
version: string
|
||||||
scriptVersion: string
|
|
||||||
location: string
|
location: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { compareString } from './classes'
|
|
||||||
|
|
||||||
const testCases: Array<{ s1: string; s2: string; res: number }> = [
|
|
||||||
{ s1: 'hello', s2: 'hello', res: 100 },
|
|
||||||
{ s1: 'aaaaa', s2: 'bbbbb', res: 0 },
|
|
||||||
{
|
|
||||||
s1: 'Mely állítás nem igaz a tőzsdékre?',
|
|
||||||
s2: 'Mely állítás nem igaz a tőzsdékre?',
|
|
||||||
res: 100,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
s1: 'Mely állítás nem igaz a tőzsdékre?',
|
|
||||||
s2: 'Ez egy teljesen más mondat',
|
|
||||||
res: 0,
|
|
||||||
},
|
|
||||||
{ s1: 'cHar caSe tESt', s2: 'ChaR cAse TEst', res: 0 },
|
|
||||||
]
|
|
||||||
|
|
||||||
testCases.forEach((currCase) => {
|
|
||||||
const { s1, s2, res } = currCase
|
|
||||||
|
|
||||||
test(`String compare tests: "${s1}" & "${s2}" should be: ${res}%`, () => {
|
|
||||||
expect(compareString(s1, s1.split(' '), s2, s2.split(' '))).toBe(res)
|
|
||||||
})
|
|
||||||
})
|
|
|
@ -87,20 +87,12 @@ export function doALongTask(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initWorkerPool(initData: any): void {
|
export function initWorkerPool(initData: any): Array<WorkerObj> {
|
||||||
if (workers) {
|
if (workers) {
|
||||||
logger.Log('WORKERS ALREADY EXISTS', logger.GetColor('redbg'))
|
logger.Log('WORKERS ALREADY EXISTS', logger.GetColor('redbg'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
workers = []
|
workers = []
|
||||||
const factory = {
|
|
||||||
create: function(index) {
|
|
||||||
return getAWorker(index, initData)
|
|
||||||
},
|
|
||||||
destroy: function(client) {
|
|
||||||
client.worker.terminate()
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const threadCount = process.env.NS_THREAD_COUNT || os.cpus().length
|
const threadCount = process.env.NS_THREAD_COUNT || os.cpus().length
|
||||||
if (process.env.NS_THREAD_COUNT) {
|
if (process.env.NS_THREAD_COUNT) {
|
||||||
|
@ -112,11 +104,13 @@ export function initWorkerPool(initData: any): void {
|
||||||
|
|
||||||
for (let i = 0; i < threadCount; i++) {
|
for (let i = 0; i < threadCount; i++) {
|
||||||
workers.push({
|
workers.push({
|
||||||
worker: factory.create(i),
|
worker: getAWorker(i, initData),
|
||||||
index: i,
|
index: i,
|
||||||
free: true,
|
free: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return workers
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -169,7 +163,7 @@ function processJob() {
|
||||||
freeWorker.free = true
|
freeWorker.free = true
|
||||||
job.doneEvent.emit('done', res)
|
job.doneEvent.emit('done', res)
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function (err) {
|
||||||
handleWorkerError(freeWorker, err)
|
handleWorkerError(freeWorker, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d06e9900445ca8af4ee354244b056f24bb76bc0c
|
Subproject commit 27211c7bc83e0e930fabc430ffb5615b52523106
|
|
@ -1 +1 @@
|
||||||
Subproject commit ae9a168ada577d65a71ac27ef3959624ed3e71da
|
Subproject commit 11e7c5c5679457e999a95bd24b80108f6d7811ab
|
Loading…
Add table
Add a link
Reference in a new issue