core: ignore empty ids

This commit is contained in:
undefined committed 2021-05-21 17:38:39 +08:00
1 parent f3e25eccbe
commit bcd6ad5b3f
4 files changed
+9 -5

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.26.21",
"version": "2.26.22",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+2 -2
View File
@@ -214,7 +214,7 @@ class ContestEditHandler extends Handler {
domainId: string, beginAtDate: string, beginAtTime: string, duration: number,
title: string, content: string, rule: string, _pids: string, rated = false,
) {
const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i);
const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i).filter((i) => i);
await problem.getList(domainId, pids, this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN), true);
const beginAtMoment = moment.tz(`${beginAtDate} ${beginAtTime}`, this.user.timeZone);
if (!beginAtMoment.isValid()) {
@@ -425,7 +425,7 @@ class ContestCreateHandler extends Handler {
domainId: string, beginAtDate: string, beginAtTime: string, duration: number,
title: string, content: string, rule: string, _pids: string, rated = false,
) {
const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i);
const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i).filter((i) => i);
const beginAt = moment.tz(`${beginAtDate} ${beginAtTime}`, this.user.timeZone);
if (!beginAt.isValid()) throw new ValidationError('beginAtDate', 'beginAtTime');
const endAt = beginAt.clone().add(duration, 'hours').toDate();
+2 -2
View File
@@ -259,7 +259,7 @@ class HomeworkCreateHandler extends Handler {
penaltySinceDate: string, penaltySinceTime: string, extensionDays: number,
penaltyRules: PenaltyRules, title: string, content: string, _pids: string, rated = false,
) {
const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i);
const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i).filter((i) => i);
const beginAt = moment.tz(`${beginAtDate} ${beginAtTime}`, this.user.timeZone);
if (!beginAt.isValid()) throw new ValidationError('beginAtDate', 'beginAtTime');
const penaltySince = moment.tz(`${penaltySinceDate} ${penaltySinceTime}`, this.user.timeZone);
@@ -323,7 +323,7 @@ class HomeworkEditHandler extends Handler {
penaltySinceDate: string, penaltySinceTime: string, extensionDays: number,
penaltyRules: string, title: string, content: string, _pids: string, rated = false,
) {
const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i);
const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i).filter((i) => i);
const tdoc = await contest.get(domainId, tid, document.TYPE_HOMEWORK);
if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_HOMEWORK);
else this.checkPerm(PERM.PERM_EDIT_HOMEWORK_SELF);
+4
View File
@@ -629,6 +629,10 @@ export class ProblemPrefixListHandler extends Handler {
@param('prefix', Types.Name)
async get(domainId: string, prefix: string) {
this.response.body = await problem.getPrefixList(domainId, prefix);
if (!Number.isNaN(+prefix)) {
const pdoc = await problem.get(domainId, +prefix, undefined, ['domainId', 'docId', 'pid', 'title']);
if (pdoc) this.response.body.unshift(pdoc);
}
}
}