mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: problem.get with raw config
This commit is contained in:
1 parent
973f19db68
commit
f768e96867
2 files changed
+3
-2
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.1.32",
|
"version": "3.1.33",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ export class ProblemModel {
|
|||||||
static async get(
|
static async get(
|
||||||
domainId: string, pid: string | number,
|
domainId: string, pid: string | number,
|
||||||
projection: Projection<ProblemDoc> = ProblemModel.PROJECTION_PUBLIC,
|
projection: Projection<ProblemDoc> = ProblemModel.PROJECTION_PUBLIC,
|
||||||
|
rawConfig = false,
|
||||||
): Promise<ProblemDoc | null> {
|
): Promise<ProblemDoc | null> {
|
||||||
if (typeof pid !== 'number') {
|
if (typeof pid !== 'number') {
|
||||||
if (Number.isSafeInteger(parseInt(pid, 10))) pid = parseInt(pid, 10);
|
if (Number.isSafeInteger(parseInt(pid, 10))) pid = parseInt(pid, 10);
|
||||||
@@ -116,7 +117,7 @@ export class ProblemModel {
|
|||||||
: (await document.getMulti(domainId, document.TYPE_PROBLEM, { pid }).toArray())[0];
|
: (await document.getMulti(domainId, document.TYPE_PROBLEM, { pid }).toArray())[0];
|
||||||
if (!res) return null;
|
if (!res) return null;
|
||||||
try {
|
try {
|
||||||
res.config = await parseConfig(res.config);
|
if (!rawConfig) res.config = await parseConfig(res.config);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
res.config = `Cannot parse: ${e.message}`;
|
res.config = `Cannot parse: ${e.message}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user