core: sync rdoc.score to psdoc.score

This commit is contained in:
undefined committed 2021-05-06 12:10:22 +08:00
1 parent fda62809a1
commit 9e94ede71f
5 files changed
+27 -5

No files matched your search

+12
View File
@@ -1,6 +1,8 @@
/* eslint-disable no-await-in-loop */
import { FilterQuery } from 'mongodb';
import type { DomainDoc, Udoc } from './interface';
import domain from './model/domain';
import * as document from './model/document';
import user from './model/user';
import problem, { Field, Pdoc } from './model/problem';
@@ -14,6 +16,16 @@ export async function iterateAllUser(cb: (udoc: Udoc, current?: number, total?:
for (const i in udocs) await cb(udocs[i], +i, udocs.length);
}
export async function iterateAllPsdoc(filter: FilterQuery<any>, cb: (psdoc: any) => Promise<any>) {
await iterateAllDomain(async ({ _id: domainId }) => {
const cursor = document.getMultiStatus(domainId, document.TYPE_PROBLEM, filter);
while (await cursor.hasNext()) {
const psdoc = await cursor.next();
await cb(psdoc);
}
});
}
interface PartialPdoc extends Pdoc {
[key: string]: any,
}