core: always pick tsdoc endAt field (#1156)

This commit is contained in:
Baoshuo authored and GitHub committed 2026-05-07 23:33:45 +08:00
1 parent cc74b995ee
commit e3fa08f56c
2 files changed
+3 -3

No files matched your search

+2 -1
View File
@@ -195,7 +195,8 @@ export class ContestDetailHandler extends ContestDetailBaseHandler {
if (this.tdoc.rule === 'homework') throw new ContestNotFoundError(domainId, tid); if (this.tdoc.rule === 'homework') throw new ContestNotFoundError(domainId, tid);
if (!this.tsdoc?.attend) throw new ContestNotAttendedError(domainId, tid); if (!this.tsdoc?.attend) throw new ContestNotAttendedError(domainId, tid);
if (!contest.isOngoing(this.tdoc, this.tsdoc)) throw new ContestNotLiveError(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(); this.back();
} }
} }
+1 -2
View File
@@ -366,8 +366,7 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
: problem.canViewBy(this.pdoc, this.user) ? 'correction' : 'none', : problem.canViewBy(this.pdoc, this.user) ? 'correction' : 'none',
}; };
if (this.tdoc && this.tsdoc) { if (this.tdoc && this.tsdoc) {
const fields = ['attend', 'startAt']; const fields = ['attend', 'startAt', 'endAt'];
if (this.tdoc.duration) fields.push('endAt');
if (contest.canShowSelfRecord.call(this, this.tdoc, true)) fields.push('detail'); if (contest.canShowSelfRecord.call(this, this.tdoc, true)) fields.push('detail');
this.tsdoc = pick(this.tsdoc, fields); this.tsdoc = pick(this.tsdoc, fields);
this.response.body.tsdoc = this.tsdoc; this.response.body.tsdoc = this.tsdoc;