core: 修正比赛中的提交被标记为hidden的问题

This commit is contained in:
undefined committed 2020-11-08 13:01:04 +08:00
1 parent 58807c4148
commit 1afb022c32
3 files changed
+17 -9

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.13.44", "version": "2.13.45",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
+14 -7
View File
@@ -1,4 +1,4 @@
import { ObjectID } from 'mongodb'; import { FilterQuery, ObjectID } from 'mongodb';
import { PermissionError, RecordNotFoundError } from '../error'; import { PermissionError, RecordNotFoundError } from '../error';
import { PERM, CONSTANT, STATUS } from '../model/builtin'; import { PERM, CONSTANT, STATUS } from '../model/builtin';
import * as problem from '../model/problem'; import * as problem from '../model/problem';
@@ -23,14 +23,21 @@ class RecordListHandler extends RecordHandler {
@param('uidOrName', Types.String, true) @param('uidOrName', Types.String, true)
async get(domainId: string, page = 1, pid?: string, tid?: ObjectID, uidOrName?: string) { async get(domainId: string, page = 1, pid?: string, tid?: ObjectID, uidOrName?: string) {
this.response.template = 'record_main.html'; this.response.template = 'record_main.html';
const q: any = { tid, hidden: false }; const q: FilterQuery<Rdoc> = { 'contest.tid': tid, hidden: false };
if (uidOrName) { if (uidOrName) {
q.$or = [ let udoc = await user.getById(domainId, +uidOrName);
{ unameLower: uidOrName.toLowerCase() }, if (udoc) q.uid = udoc._id;
{ _id: parseInt(uidOrName, 10) }, else {
]; udoc = await user.getByUname(domainId, uidOrName);
if (udoc) q.uid = udoc._id;
else q.uid = null;
}
}
if (pid) {
const pdoc = await problem.get(domainId, pid);
if (pdoc) q.pid = pdoc.docId;
else q.pid = null;
} }
if (pid) q.pid = pid;
const [rdocs] = await paginate( const [rdocs] = await paginate(
record.getMulti(domainId, q).sort('_id', -1), record.getMulti(domainId, q).sort('_id', -1),
page, page,
+2 -1
View File
@@ -89,7 +89,7 @@ export async function add(
score: 0, score: 0,
time: 0, time: 0,
memory: 0, memory: 0,
hidden: !!contestOrConfig, hidden: false,
judgeTexts: [], judgeTexts: [],
compilerTexts: [], compilerTexts: [],
testCases: [], testCases: [],
@@ -102,6 +102,7 @@ export async function add(
data.contest = contestOrConfig as ContestInfo; data.contest = contestOrConfig as ContestInfo;
} else { } else {
data.config = contestOrConfig as RunConfig; data.config = contestOrConfig as RunConfig;
data.hidden = true;
} }
} }
const res = await coll.insertOne(data); const res = await coll.insertOne(data);