mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
ask api changes, so it wont search unnecesary question dbs
This commit is contained in:
parent
0463ab3cd2
commit
b53fd84bf2
5 changed files with 116 additions and 65 deletions
|
@ -315,7 +315,7 @@ function questionToString(question: Question) {
|
|||
// ---------------------------------------------------------------------------------------------------------
|
||||
// Subject
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
function searchQuestion(
|
||||
function searchSubject(
|
||||
subj: Subject,
|
||||
question: Question,
|
||||
subjName: string,
|
||||
|
@ -465,7 +465,7 @@ function doSearch(
|
|||
.includes(getSubjNameWithoutYear(subj.Name).toLowerCase())
|
||||
) {
|
||||
logger.DebugLog(`Searching in ${subj.Name} `, 'searchworker', 2)
|
||||
const subjRes = searchQuestion(
|
||||
const subjRes = searchSubject(
|
||||
subj,
|
||||
questionToSearch,
|
||||
subjName,
|
||||
|
@ -473,14 +473,13 @@ function doSearch(
|
|||
)
|
||||
result = result.concat(subjRes)
|
||||
if (searchTillMatchPercent) {
|
||||
// TODO: this should return true to continue searching?
|
||||
return subjRes.every((sr) => {
|
||||
return sr.match <= searchTillMatchPercent
|
||||
return !subjRes.some((sr) => {
|
||||
return sr.match >= searchTillMatchPercent
|
||||
})
|
||||
}
|
||||
return true
|
||||
}
|
||||
// TODO: data.every should always return something! true or false?
|
||||
return true
|
||||
})
|
||||
|
||||
if (searchInAllIfNoResult) {
|
||||
|
@ -495,18 +494,19 @@ function doSearch(
|
|||
1
|
||||
)
|
||||
data.every((subj) => {
|
||||
const subjRes = searchQuestion(
|
||||
const subjRes = searchSubject(
|
||||
subj,
|
||||
questionToSearch,
|
||||
subjName,
|
||||
searchTillMatchPercent
|
||||
)
|
||||
result = result.concat(subjRes)
|
||||
|
||||
if (searchTillMatchPercent) {
|
||||
// TODO: this should return true to continue searching?
|
||||
return subjRes.every((sr) => {
|
||||
return sr.match < searchTillMatchPercent
|
||||
const continueSearching = !subjRes.some((sr) => {
|
||||
return sr.match >= searchTillMatchPercent
|
||||
})
|
||||
return continueSearching
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
@ -546,11 +546,10 @@ if (!isMainThread) {
|
|||
questionData,
|
||||
searchTillMatchPercent,
|
||||
searchInAllIfNoResult,
|
||||
searchIn,
|
||||
index,
|
||||
} = msg.data
|
||||
|
||||
const index = msg.index
|
||||
const searchIn = msg.data.searchIn
|
||||
|
||||
// console.log(
|
||||
// `[THREAD #${workerIndex}]: staring work${
|
||||
// !isNaN(index) ? ` on job index #${index}` : ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue