mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Workers can now search in multiple specified db-s
This commit is contained in:
parent
68dcbff846
commit
19b8fdc5ab
5 changed files with 57 additions and 52 deletions
|
@ -22,7 +22,7 @@ const dataLockFile = './data/lockData'
|
|||
|
||||
import logger from '../utils/logger'
|
||||
import { createQuestion } from '../utils/classes'
|
||||
import { doALongTask } from './workerPool'
|
||||
import { doALongTask } from './workerPool'
|
||||
import idStats from '../utils/ids'
|
||||
import utils from '../utils/utils'
|
||||
import { SearchResult, addQuestion, getSubjNameWithoutYear } from './classes'
|
||||
|
@ -45,7 +45,7 @@ export interface RecievedData {
|
|||
scriptVersion: string
|
||||
}
|
||||
|
||||
interface Result {
|
||||
export interface Result {
|
||||
qdbName: string
|
||||
newQuestions: number
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ export function processIncomingRequest(
|
|||
return new Promise((resolve) => resolve([]))
|
||||
}
|
||||
|
||||
// FIXME: this many promises and stuff might be unnecesarry
|
||||
const promises: Array<Promise<Result>> = questionDbs.reduce((acc, qdb) => {
|
||||
if (qdb.shouldSave(recievedData)) {
|
||||
acc.push(processIncomingRequestUsingDb(recievedData, qdb, dryRun, user))
|
||||
|
@ -202,8 +203,6 @@ function processIncomingRequestUsingDb(
|
|||
)
|
||||
logger.DebugLog(currentQuestion, 'actions', 3)
|
||||
addQuestion(qdb.data, sName, currentQuestion)
|
||||
// TODO: check if it really adds it, not only just some clone (questionDbs in api.ts
|
||||
// modifies too)
|
||||
})
|
||||
|
||||
currWrites++
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue