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)
|
||||
})
|
||||
|
||||
Promise.all(resultPromises).then((result) => {
|
||||
console.log(result)
|
||||
res.json(result)
|
||||
Promise.all(resultPromises).then((results) => {
|
||||
res.json(
|
||||
results.map((result: any) => {
|
||||
return {
|
||||
answers: result.result,
|
||||
question: result.question,
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1145,6 +1151,8 @@ function GetApp(): ModuleType {
|
|||
|
||||
function getResult(question, subj, recData, recievedData) {
|
||||
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({
|
||||
type: 'work',
|
||||
data: {
|
||||
|
@ -1154,17 +1162,17 @@ function GetApp(): ModuleType {
|
|||
questionData: recData,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
console.log(result)
|
||||
.then((taskResult) => {
|
||||
try {
|
||||
logger.DebugLog(
|
||||
`Question result length: ${result.length}`,
|
||||
`Question result length: ${taskResult.length}`,
|
||||
'ask',
|
||||
1
|
||||
)
|
||||
logger.DebugLog(result, 'ask', 2)
|
||||
logger.DebugLog(taskResult, 'ask', 2)
|
||||
resolve({
|
||||
result: result,
|
||||
question: question,
|
||||
result: taskResult.result,
|
||||
success: true,
|
||||
})
|
||||
} catch (err) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue