mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fullStatus
This commit is contained in:
1 parent
5153a7a871
commit
b2fe14ffe7
5 files changed
+23
-41
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.28.43",
|
"version": "2.28.44",
|
||||||
"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",
|
||||||
|
|||||||
@@ -25,10 +25,15 @@ class RecordListHandler extends Handler {
|
|||||||
@param('tid', Types.ObjectID, true)
|
@param('tid', Types.ObjectID, true)
|
||||||
@param('uidOrName', Types.Name, true)
|
@param('uidOrName', Types.Name, true)
|
||||||
@param('status', Types.Int, true)
|
@param('status', Types.Int, true)
|
||||||
|
@param('fullStatus', Types.Boolean)
|
||||||
@param('allDomain', Types.Boolean, true)
|
@param('allDomain', Types.Boolean, true)
|
||||||
async get(domainId: string, page = 1, pid?: string, tid?: ObjectID, uidOrName?: string, status?: number, all = false) {
|
async get(
|
||||||
|
domainId: string, page = 1, pid?: string, tid?: ObjectID,
|
||||||
|
uidOrName?: string, status?: number, full = false, all = false,
|
||||||
|
) {
|
||||||
this.response.template = 'record_main.html';
|
this.response.template = 'record_main.html';
|
||||||
const q: FilterQuery<RecordDoc> = { 'contest.tid': tid, hidden: false };
|
const q: FilterQuery<RecordDoc> = { 'contest.tid': tid, hidden: false };
|
||||||
|
if (full) uidOrName = this.user._id.toString();
|
||||||
if (tid) {
|
if (tid) {
|
||||||
const tdoc = await contest.get(domainId, tid, -1);
|
const tdoc = await contest.get(domainId, tid, -1);
|
||||||
if (!tdoc) throw new ContestNotFoundError(domainId, pid);
|
if (!tdoc) throw new ContestNotFoundError(domainId, pid);
|
||||||
@@ -49,27 +54,21 @@ class RecordListHandler extends Handler {
|
|||||||
else q.pid = null;
|
else q.pid = null;
|
||||||
}
|
}
|
||||||
if (status) q.status = status;
|
if (status) q.status = status;
|
||||||
const [rdocs] = await paginate(
|
let cursor = record.getMulti(domainId, q).sort('_id', -1);
|
||||||
record.getMulti(domainId, q).sort('_id', -1).project(buildProjection(record.PROJECTION_LIST)),
|
if (!full) cursor = cursor.project(buildProjection(record.PROJECTION_LIST));
|
||||||
page,
|
const [rdocs] = await paginate(cursor, page, full ? 10 : system.get('pagination.record'));
|
||||||
system.get('pagination.record'),
|
|
||||||
);
|
|
||||||
const canViewProblem = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM);
|
const canViewProblem = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM);
|
||||||
const canViewProblemHidden = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
const canViewProblemHidden = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||||
const [udict, pdict] = await Promise.all([
|
const [udict, pdict] = full ? [{}, {}]
|
||||||
user.getList(domainId, rdocs.map((rdoc) => rdoc.uid)),
|
: await Promise.all([
|
||||||
canViewProblem
|
user.getList(domainId, rdocs.map((rdoc) => rdoc.uid)),
|
||||||
? problem.getList(domainId, rdocs.map(
|
canViewProblem
|
||||||
(rdoc) => (rdoc.domainId === domainId ? rdoc.pid : `${rdoc.pdomain}:${rdoc.pid}`),
|
? problem.getList(domainId, rdocs.map(
|
||||||
), canViewProblemHidden, false)
|
(rdoc) => (rdoc.domainId === domainId ? rdoc.pid : `${rdoc.pdomain}:${rdoc.pid}`),
|
||||||
: Object.fromEntries([rdocs.map((rdoc) => [rdoc.pid, { ...problem.default, pid: rdoc.pid }])]),
|
), canViewProblemHidden, false)
|
||||||
]);
|
: Object.fromEntries([rdocs.map((rdoc) => [rdoc.pid, { ...problem.default, pid: rdoc.pid }])]),
|
||||||
const path = [
|
]);
|
||||||
['Hydro', 'homepage'],
|
|
||||||
['record_main', null],
|
|
||||||
];
|
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
path,
|
|
||||||
page,
|
page,
|
||||||
rdocs,
|
rdocs,
|
||||||
pdict,
|
pdict,
|
||||||
@@ -79,7 +78,7 @@ class RecordListHandler extends Handler {
|
|||||||
filterUidOrName: uidOrName,
|
filterUidOrName: uidOrName,
|
||||||
filterStatus: status,
|
filterStatus: status,
|
||||||
};
|
};
|
||||||
if (this.user.hasPriv(PRIV.PRIV_VIEW_JUDGE_STATISTICS)) {
|
if (this.user.hasPriv(PRIV.PRIV_VIEW_JUDGE_STATISTICS) && !full) {
|
||||||
this.response.body.statistics = {
|
this.response.body.statistics = {
|
||||||
...await record.stat(all ? undefined : domainId),
|
...await record.stat(all ? undefined : domainId),
|
||||||
delay: await TaskModel.getDelay({ type: 'judge' }),
|
delay: await TaskModel.getDelay({ type: 'judge' }),
|
||||||
|
|||||||
@@ -202,23 +202,6 @@ class RecordModel {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ArgMethod
|
|
||||||
static getUserInProblemMulti(domainId: string, uid: number, pid: ExternalProblemId | number, contestInfo?: ContestInfo) {
|
|
||||||
let pdomain = domainId;
|
|
||||||
if (typeof pid === 'string') {
|
|
||||||
pdomain = pid.split(':')[0];
|
|
||||||
pid = +pid.split(':')[1];
|
|
||||||
}
|
|
||||||
if (!contestInfo) {
|
|
||||||
return RecordModel.coll.find({
|
|
||||||
domainId, uid, pdomain, pid, contest: null,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return RecordModel.coll.find({
|
|
||||||
domainId, uid, pdomain, pid, contest: contestInfo,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@ArgMethod
|
@ArgMethod
|
||||||
static getByUid(domainId: string, uid: number, limit: number): Promise<RecordDoc[]> {
|
static getByUid(domainId: string, uid: number, limit: number): Promise<RecordDoc[]> {
|
||||||
return RecordModel.coll.find({ domainId, uid, hidden: false }).sort({ _id: -1 }).limit(limit).toArray();
|
return RecordModel.coll.find({ domainId, uid, hidden: false }).sort({ _id: -1 }).limit(limit).toArray();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.11.30",
|
"version": "4.11.31",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -12,13 +12,13 @@
|
|||||||
{% if tdoc %}
|
{% if tdoc %}
|
||||||
{{ set(UiContext, 'canViewRecord', model.contest.canShowRecord.call(handler, tdoc)) }}
|
{{ set(UiContext, 'canViewRecord', model.contest.canShowRecord.call(handler, tdoc)) }}
|
||||||
{{ set(UiContext, 'postSubmitUrl', url('contest_detail_problem_submit' if tdoc.docType == model.document.TYPE_CONTEST else 'homework_detail_problem_submit', pid=pdoc.pid, tid=tdoc.docId)) }}
|
{{ set(UiContext, 'postSubmitUrl', url('contest_detail_problem_submit' if tdoc.docType == model.document.TYPE_CONTEST else 'homework_detail_problem_submit', pid=pdoc.pid, tid=tdoc.docId)) }}
|
||||||
{{ set(UiContext, 'getSubmissionsUrl', url('record_main', query={uidOrName:handler.user._id, pid:pdoc.pid, tid:tdoc.docId})) }}
|
{{ set(UiContext, 'getSubmissionsUrl', url('record_main', query={fullStatus:'true', pid:pdoc.pid, tid:tdoc.docId})) }}
|
||||||
{{ set(UiContext, 'getRecordDetailUrl', url('record_detail', rid='{rid}', query={tid:tdoc.docId})) }}
|
{{ set(UiContext, 'getRecordDetailUrl', url('record_detail', rid='{rid}', query={tid:tdoc.docId})) }}
|
||||||
{{ set(UiContext, 'pretestConnUrl', "/record-conn?pretest=1&uid=" + handler.user._id + "&pid=" + pdoc.domainId + ":" + pdoc.docId + "&domainId=" + handler.domainId + "&tid=" + tdoc.docId) }}
|
{{ set(UiContext, 'pretestConnUrl', "/record-conn?pretest=1&uid=" + handler.user._id + "&pid=" + pdoc.domainId + ":" + pdoc.docId + "&domainId=" + handler.domainId + "&tid=" + tdoc.docId) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ set(UiContext, 'canViewRecord', true) }}
|
{{ set(UiContext, 'canViewRecord', true) }}
|
||||||
{{ set(UiContext, 'postSubmitUrl', url('problem_submit', pid=pdoc.docId)) }}
|
{{ set(UiContext, 'postSubmitUrl', url('problem_submit', pid=pdoc.docId)) }}
|
||||||
{{ set(UiContext, 'getSubmissionsUrl', url('record_main', query={uidOrName:handler.user._id, pid:pdoc.docId})) }}
|
{{ set(UiContext, 'getSubmissionsUrl', url('record_main', query={fullStatus:'true', pid:pdoc.docId})) }}
|
||||||
{{ set(UiContext, 'getRecordDetailUrl', url('record_detail', rid='{rid}')) }}
|
{{ set(UiContext, 'getRecordDetailUrl', url('record_detail', rid='{rid}')) }}
|
||||||
{{ set(UiContext, 'pretestConnUrl', "/record-conn?pretest=1&uid=" + handler.user._id + "&pid=" + pdoc.docId + "&domainId=" + handler.domainId) }}
|
{{ set(UiContext, 'pretestConnUrl', "/record-conn?pretest=1&uid=" + handler.user._id + "&pid=" + pdoc.docId + "&domainId=" + handler.domainId) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in new issue
Block a user