mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2026-04-29 03:37:38 +02:00
Fixed bugs that came from declassifying classes.js
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
const { isMainThread, parentPort, workerData } = require('worker_threads')
|
||||
const logger = require('../utils/logger.js')
|
||||
const actions = require('../utils/actions.js')
|
||||
const classes = require('./classes.js')
|
||||
classes.initLogger(logger.DebugLog)
|
||||
const { createQuestion, searchData } = require('./classes.js')
|
||||
|
||||
const minMatchAmmountToAdd = 90 // FIXME: test this value
|
||||
|
||||
if (!isMainThread) {
|
||||
logger.DebugLog('Starting worker thread', 'processdata', 1)
|
||||
logger.DebugLog(workerData, 'processdata', 1)
|
||||
logger.DebugLog(workerData, 'processdata', 3)
|
||||
|
||||
parentPort.postMessage(
|
||||
ProcessData(workerData.data, actions.LoadJSONFromObject(workerData.qdb))
|
||||
)
|
||||
parentPort.postMessage(ProcessData(workerData.data, workerData.qdb))
|
||||
} else {
|
||||
logger.Log(
|
||||
'Porcess data should not run on main thread!',
|
||||
@@ -26,15 +22,11 @@ function ProcessData(data, qdb) {
|
||||
data.quiz.forEach((question) => {
|
||||
logger.DebugLog('Question:', 'actions', 2)
|
||||
logger.DebugLog(question, 'actions', 2)
|
||||
let currentQuestion = new classes.Question(
|
||||
question.Q,
|
||||
question.A,
|
||||
question.data
|
||||
)
|
||||
let currentQuestion = createQuestion(question.Q, question.A, question.data)
|
||||
logger.DebugLog('Searching for question in subj ' + data.subj, 'actions', 3)
|
||||
logger.DebugLog(currentQuestion, 'actions', 3)
|
||||
|
||||
let sames = qdb.Search(currentQuestion, data.subj)
|
||||
let sames = searchData(qdb, currentQuestion, data.subj)
|
||||
logger.DebugLog('Same questions:', 'actions', 2)
|
||||
logger.DebugLog('Length: ' + sames.length, 'actions', 2)
|
||||
logger.DebugLog(sames, 'actions', 3)
|
||||
|
||||
Reference in New Issue
Block a user