mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
/ask POST fixes
This commit is contained in:
parent
c6da65ce40
commit
0654a36d21
1 changed files with 16 additions and 8 deletions
|
@ -1106,9 +1106,15 @@ function GetApp(): ModuleType {
|
||||||
return getResult(question, subj, null, req.query)
|
return getResult(question, subj, null, req.query)
|
||||||
})
|
})
|
||||||
|
|
||||||
Promise.all(resultPromises).then((result) => {
|
Promise.all(resultPromises).then((results) => {
|
||||||
console.log(result)
|
res.json(
|
||||||
res.json(result)
|
results.map((result: any) => {
|
||||||
|
return {
|
||||||
|
answers: result.result,
|
||||||
|
question: result.question,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1145,6 +1151,8 @@ function GetApp(): ModuleType {
|
||||||
|
|
||||||
function getResult(question, subj, recData, recievedData) {
|
function getResult(question, subj, recData, recievedData) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
// searchIn could be [0], [1], ... to search every db in different thread. Put this into a
|
||||||
|
// forEach(qdbs) to achieve this
|
||||||
doALongTask({
|
doALongTask({
|
||||||
type: 'work',
|
type: 'work',
|
||||||
data: {
|
data: {
|
||||||
|
@ -1154,17 +1162,17 @@ function GetApp(): ModuleType {
|
||||||
questionData: recData,
|
questionData: recData,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((taskResult) => {
|
||||||
console.log(result)
|
|
||||||
try {
|
try {
|
||||||
logger.DebugLog(
|
logger.DebugLog(
|
||||||
`Question result length: ${result.length}`,
|
`Question result length: ${taskResult.length}`,
|
||||||
'ask',
|
'ask',
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
logger.DebugLog(result, 'ask', 2)
|
logger.DebugLog(taskResult, 'ask', 2)
|
||||||
resolve({
|
resolve({
|
||||||
result: result,
|
question: question,
|
||||||
|
result: taskResult.result,
|
||||||
success: true,
|
success: true,
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue