diff --git a/packages/hydrooj/src/handler/contest.ts b/packages/hydrooj/src/handler/contest.ts index 5b63f4440..569bd0009 100644 --- a/packages/hydrooj/src/handler/contest.ts +++ b/packages/hydrooj/src/handler/contest.ts @@ -195,7 +195,8 @@ export class ContestDetailHandler extends ContestDetailBaseHandler { if (this.tdoc.rule === 'homework') throw new ContestNotFoundError(domainId, tid); if (!this.tsdoc?.attend) throw new ContestNotAttendedError(domainId, tid); if (!contest.isOngoing(this.tdoc, this.tsdoc)) throw new ContestNotLiveError(domainId, tid); - await contest.setStatus(domainId, tid, this.user._id, { endAt: new Date() }); + const now = new Date(); + await contest.setStatus(domainId, tid, this.user._id, { endAt: now, ...(!this.tsdoc.startAt ? { startAt: now } : {}) }); this.back(); } } diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index e9d283d95..9aea232c6 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -366,8 +366,7 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler { : problem.canViewBy(this.pdoc, this.user) ? 'correction' : 'none', }; if (this.tdoc && this.tsdoc) { - const fields = ['attend', 'startAt']; - if (this.tdoc.duration) fields.push('endAt'); + const fields = ['attend', 'startAt', 'endAt']; if (contest.canShowSelfRecord.call(this, this.tdoc, true)) fields.push('detail'); this.tsdoc = pick(this.tsdoc, fields); this.response.body.tsdoc = this.tsdoc;