Modified stuff for easyer testing, logging questiondb count in daily stats

This commit is contained in:
mrfry 2021-08-01 11:31:09 +02:00
parent d7b5ad8160
commit cc19b5424b
8 changed files with 11 additions and 40 deletions

View file

@ -1 +0,0 @@
[]

View file

@ -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) {

View file

@ -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

View file

@ -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
} }

View file

@ -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)
})
})

View file

@ -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
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

@ -1 +1 @@
Subproject commit d06e9900445ca8af4ee354244b056f24bb76bc0c Subproject commit 27211c7bc83e0e930fabc430ffb5615b52523106

@ -1 +1 @@
Subproject commit ae9a168ada577d65a71ac27ef3959624ed3e71da Subproject commit 11e7c5c5679457e999a95bd24b80108f6d7811ab