/ask POST fixes

This commit is contained in:
mrfry 2020-12-19 15:27:18 +01:00
parent c6da65ce40
commit 0654a36d21

View file

@ -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) {