mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
sonic: do not block operations
This commit is contained in:
1 parent
69e3ebb7fb
commit
15d26eec37
3 files changed
+7
-4
No files matched your search
@@ -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) => {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user