mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: problemDetail: performance update
This commit is contained in:
1 parent
a0aa173b79
commit
4c27523e32
2 files changed
+4
-6
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.3.19",
|
||||
"version": "3.3.20",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -121,12 +121,10 @@ export class ProblemModel {
|
||||
projection: Projection<ProblemDoc> = ProblemModel.PROJECTION_PUBLIC,
|
||||
rawConfig = false,
|
||||
): Promise<ProblemDoc | null> {
|
||||
if (typeof pid !== 'number') {
|
||||
if (Number.isSafeInteger(parseInt(pid, 10))) pid = parseInt(pid, 10);
|
||||
}
|
||||
if (Number.isSafeInteger(+pid)) pid = +pid;
|
||||
const res = typeof pid === 'number'
|
||||
? await document.get(domainId, document.TYPE_PROBLEM, pid, projection)
|
||||
: (await document.getMulti(domainId, document.TYPE_PROBLEM, { pid }).toArray())[0];
|
||||
: (await document.getMulti(domainId, document.TYPE_PROBLEM, { sort: sortable(pid), pid }).toArray())[0];
|
||||
if (!res) return null;
|
||||
try {
|
||||
if (!rawConfig) res.config = await parseConfig(res.config);
|
||||
@@ -290,7 +288,7 @@ export class ProblemModel {
|
||||
): Promise<ProblemDict> {
|
||||
const r: Record<number, ProblemDoc> = {};
|
||||
const l: Record<string, ProblemDoc> = {};
|
||||
const q: any = { $or: [{ docId: { $in: pids } }, { pid: { $in: pids } }] };
|
||||
const q: any = { docId: { $in: pids } };
|
||||
let pdocs = await document.getMulti(domainId, document.TYPE_PROBLEM, q)
|
||||
.project(buildProjection(projection)).toArray();
|
||||
if (group.length > 0) {
|
||||
|
||||
Reference in new issue
Block a user