core: 修复无法根据contest_id查找评测记录的问题

This commit is contained in:
undefined committed 2020-11-08 02:16:00 +08:00
1 parent ee0f5deedc
commit a1c42af7a7
3 files changed
+10 -6

No files matched your search

+3 -4
View File
@@ -23,7 +23,6 @@ class RecordListHandler extends RecordHandler {
@param('uidOrName', Types.String, true)
async get(domainId: string, page = 1, pid?: string, tid?: ObjectID, uidOrName?: string) {
this.response.template = 'record_main.html';
if (tid) tid = new ObjectID(tid);
const q: any = { tid, hidden: false };
if (uidOrName) {
q.$or = [
@@ -171,11 +170,11 @@ class RecordMainConnectionHandler extends RecordConnectionHandler {
dispose: bus.Disposable;
@param('tid', Types.ObjectID, true)
async prepare(domainId: string, tid: ObjectID) {
async prepare(domainId: string, tid?: ObjectID) {
this.domainId = domainId;
if (tid) {
const tdoc = await contest.get(domainId, new ObjectID(tid), -1);
if (this.canShowRecord(tdoc)) this.tid = tid;
const tdoc = await contest.get(domainId, tid, -1);
if (this.canShowRecord(tdoc)) this.tid = tid.toHexString();
else {
this.close();
return;
+6 -1
View File
@@ -425,16 +425,21 @@ export class Handler {
url(name: string, kwargs: any = {}) {
let res = '#';
const args: any = {};
const query: any = {};
for (const key in kwargs) {
if (kwargs[key] instanceof ObjectID) args[key] = kwargs[key].toHexString();
else args[key] = kwargs[key].toString();
}
for (const key in kwargs.query || {}) {
if (query[key] instanceof ObjectID) query[key] = kwargs.query[key].toHexString();
else query[key] = kwargs.query[key].toString();
}
try {
if (this.domainId !== 'system' || args.domainId) {
name += '_with_domainId';
args.domainId = args.domainId || this.domainId;
}
const { anchor, query } = args;
const { anchor } = args;
if (query) res = router.url(name, args, { query });
else res = router.url(name, args);
if (anchor) return `${res}#${anchor}`;