/q json response, searching with "" subj if there is no result

This commit is contained in:
MrFry 2020-01-26 11:05:35 +01:00
parent bf86b91172
commit a1e99c53ae
3 changed files with 29 additions and 8 deletions

View file

@ -62,7 +62,13 @@ function ProcessIncomingRequest (recievedData, qdb) {
d.quiz.forEach((question) => {
let q = new classes.Question(question.Q, question.A, question.data)
let sames = qdb.Search(q, '') // TODO d.subj
let sames = qdb.Search(q, d.subj)
if (sames.length === 0) {
sames = qdb.Search(q, d.subj)
if (sames.length !== 0) {
logger.Log(`\t'${d.subj}' gave no result but '' did! (adding new questions)`, logger.GetColor('redbg'))
}
}
// if it didnt find any question, or every found questions match is lower thatn 80
let isNew = sames.length === 0 || sames.every(searchResItem => {
return searchResItem.match < classes.minMatchAmmount