diff --git a/packages/sonic/model.ts b/packages/sonic/model.ts index 0e15b2717..b9a854380 100644 --- a/packages/sonic/model.ts +++ b/packages/sonic/model.ts @@ -1,8 +1,11 @@ +import { Logger } from 'hydrooj/src/logger'; import DomainModel from 'hydrooj/src/model/domain'; import * as system from 'hydrooj/src/model/system'; import * as bus from 'hydrooj/src/service/bus'; import sonic from './service'; +const logger = new Logger('sonic'); + bus.on('problem/add', async (doc, docId) => { const union = await DomainModel.searchUnion({ union: doc.domainId, problem: true }); const tasks = []; @@ -12,7 +15,7 @@ bus.on('problem/add', async (doc, docId) => { sonic.push('problem', `${domainId}@content`, `${doc.domainId}/${docId}`, doc.content.toString()), ); } - await Promise.all(tasks); + Promise.all(tasks).catch((e) => logger.error(e)); }); bus.on('problem/edit', async (pdoc) => { @@ -27,7 +30,7 @@ bus.on('problem/edit', async (pdoc) => { .then(() => sonic.push('problem', `${domainId}@content`, id, pdoc.content.toString())), ); } - await Promise.all(tasks); + Promise.all(tasks).catch((e) => logger.error(e)); }); bus.on('problem/del', async (domainId, docId) => { diff --git a/packages/sonic/package.json b/packages/sonic/package.json index 8d435af86..d65ff0338 100644 --- a/packages/sonic/package.json +++ b/packages/sonic/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/sonic", - "version": "1.2.3", + "version": "1.2.4", "description": "Sonic search service", "main": "service.js", "typings": "service.d.ts", diff --git a/packages/sonic/script.ts b/packages/sonic/script.ts index 55ea96670..384663fdd 100644 --- a/packages/sonic/script.ts +++ b/packages/sonic/script.ts @@ -25,7 +25,7 @@ export async function run({ domainId }, report) { await Promise.all(tasks).catch((e) => console.log(`${pdoc.domainId}/${pdoc.docId}`, e)); }; if (domainId) await iterateAllProblemInDomain(domainId, ['title', 'content'], cb); - else await iterateAllProblem(['title', 'content'], cb); + else await iterateAllProblem(['title', 'content', 'tag'], cb); return true; }