From 661ceb16885478632afcfd0cc4f016e395581cd0 Mon Sep 17 00:00:00 2001 From: mrfry Date: Wed, 14 Oct 2020 13:29:10 +0200 Subject: [PATCH] Fixed added questions beeing empty arrays, removed some consolelogs --- devel/emptyData.json | 1 + devel/tests/testScripts/postTestData.sh | 4 +--- src/utils/actions.js | 13 +++++-------- src/utils/classes.js | 3 --- 4 files changed, 7 insertions(+), 14 deletions(-) create mode 100644 devel/emptyData.json diff --git a/devel/emptyData.json b/devel/emptyData.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/devel/emptyData.json @@ -0,0 +1 @@ +[] diff --git a/devel/tests/testScripts/postTestData.sh b/devel/tests/testScripts/postTestData.sh index 9b8fe33..e4cfa8c 100755 --- a/devel/tests/testScripts/postTestData.sh +++ b/devel/tests/testScripts/postTestData.sh @@ -2,11 +2,10 @@ url=$(head -n 1 ../serverAddress) echo "Server url: $url" - if [ "$#" -ne 1 ]; then echo "1 param required: json to send to localhost, got $#" else - data=$(tr -d '\n' < "$1" | awk '$1=$1') + data=$(tr -d '\n' <"$1" | awk '$1=$1') echo sending echo "SENT DATA:" ../bin/hr.sh @@ -14,4 +13,3 @@ else ../bin/hr.sh curl -X POST --data "datatoadd=$data" "$url/isAdding" fi - diff --git a/src/utils/actions.js b/src/utils/actions.js index 7acd72e..41a6c5e 100755 --- a/src/utils/actions.js +++ b/src/utils/actions.js @@ -93,9 +93,9 @@ function ProcessIncomingRequest(recievedData, qdb, infos, dryRun, user) { Promise.all(questionSearchPromises) .then((results) => { const allQuestions = [] // all new questions here that do not have result - results.forEach((result) => { + results.forEach((result, i) => { if (result.length === 0) { - allQuestions.push(result) + allQuestions.push(data.quiz[i]) } }) @@ -149,12 +149,9 @@ function ProcessIncomingRequest(recievedData, qdb, infos, dryRun, user) { logger.DebugLog(allQuestions, 'actions', 2) logger.DebugLog('ProcessIncomingRequest done', 'actions', 1) - resolve({ - newQuestions: allQLength.length, - newDb: qdb, - }) + resolve(allQuestions.length) } catch (error) { - console.log(error) + console.error(error) logger.Log( 'Error while processing processData worker result!', logger.GetColor('redbg') @@ -172,7 +169,7 @@ function ProcessIncomingRequest(recievedData, qdb, infos, dryRun, user) { console.error(err) }) } catch (err) { - console.log(err) + console.error(err) logger.Log('Couldnt parse JSON data', logger.GetColor('redbg')) reject(new Error('Couldnt parse JSON data')) } diff --git a/src/utils/classes.js b/src/utils/classes.js index 5b43612..537cca1 100755 --- a/src/utils/classes.js +++ b/src/utils/classes.js @@ -124,8 +124,6 @@ function answerPreProcessor(value) { function removeAnswerLetters(value) { assert(value) - console.log(value) - let val = value.split('. ') if (val[0].length < 2 && val.length > 1) { val.shift() @@ -382,7 +380,6 @@ function searchData(data, question, subjName, questionData) { logger.DebugLog('No subject name as param!', 'qdb search', 1) } question = simplifyQuestion(question) - console.log('RESULT: ' + question) const worker = new Worker(searchDataWorkerFile, { workerData: { data, subjName, question, questionData },