mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
bug fix
This commit is contained in:
1 parent
63bf550311
commit
d9f13feade
17 files changed
+54
-34
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/sonic",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"description": "Sonic search service",
|
||||
"main": "service.js",
|
||||
"typings": "service.d.ts",
|
||||
|
||||
@@ -3,12 +3,17 @@ import sonic from './service';
|
||||
|
||||
export const description = 'Sonic problem search re-index';
|
||||
|
||||
export async function run({ domainId }) {
|
||||
export async function run({ domainId }, report) {
|
||||
if (domainId) await sonic.flushb('problem', domainId);
|
||||
else await sonic.flushc('problem');
|
||||
let i = 0;
|
||||
const cb = async (pdoc) => {
|
||||
await sonic.push('problem', `${pdoc.domainId}@title`, pdoc.docId.toString(), pdoc.title);
|
||||
await sonic.push('problem', `${pdoc.domainId}@content`, pdoc.docId.toString(), pdoc.content.toString());
|
||||
i++;
|
||||
if (!(i % 1000)) report({ message: `${i} problems indexed` });
|
||||
await Promise.all([
|
||||
sonic.push('problem', `${pdoc.domainId}@title`, pdoc.docId.toString(), pdoc.title),
|
||||
sonic.push('problem', `${pdoc.domainId}@content`, pdoc.docId.toString(), pdoc.content.toString()),
|
||||
]).catch((e) => console.log(`${pdoc.domainId}/${pdoc.docId}`, e));
|
||||
};
|
||||
if (domainId) await iterateAllProblemInDomain(domainId, ['title', 'content'], cb);
|
||||
else await iterateAllProblem(['title', 'content'], cb);
|
||||
|
||||
Reference in new issue
Block a user