core&ui: show history judge time

This commit is contained in:
undefined committed 2025-03-16 23:10:52 +00:00
1 parent cd92a41090
commit 3c65c27911
2 files changed
+7 -6

No files matched your search

+4 -3
View File
@@ -157,8 +157,9 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
// eslint-disable-next-line consistent-return
async get(domainId: string, rid: ObjectId, download = false, rev?: ObjectId) {
let rdoc = this.rdoc;
const allRev: ObjectId[] = (await record.collHistory.find({ rid }).project({ _id: 1 }).toArray()).map((i) => i._id);
if (rev && allRev.some((i) => i.equals(rev))) {
const allRev = await record.collHistory.find({ rid }).project({ _id: 1, judgeAt: 1 }).sort({ _id: -1 }).toArray();
const allRevs: Record<string, Date> = Object.fromEntries(allRev.map((i) => [i._id.toString(), i.judgeAt]));
if (rev && allRevs[rev.toString()]) {
rdoc = { ...rdoc, ...omit(await record.collHistory.findOne({ _id: rev }), ['_id']) };
}
let canViewDetail = true;
@@ -203,7 +204,7 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
} else if (download) return await this.download();
this.response.template = 'record_detail.html';
this.response.body = {
udoc, rdoc: canViewDetail ? rdoc : pick(rdoc, ['_id', 'lang', 'code']), pdoc, tdoc: this.tdoc, rev, allRev,
udoc, rdoc: canViewDetail ? rdoc : pick(rdoc, ['_id', 'lang', 'code']), pdoc, tdoc: this.tdoc, rev, allRevs,
};
}
@@ -106,7 +106,7 @@
{% endif %}
</div>
</div>
{% if allRev|length %}
{% if allRevs|length %}
<div class="section side">
<div class="section__header">
<h1 class="section__title">{{ _('History') }}</h1>
@@ -118,10 +118,10 @@
{{ _('Latest Version') }}
</a>
</li>
{% for r in allRev %}
{% for r, rtime in allRevs %}
<li class="menu__item">
<a href="?rev={{ r }}" {% if rev and rev.equals(r) %}style="border-color: #4690d0;"{% endif %} class="menu__link">
{{ _('Version') }} {{ loop.index }}
{{ datetimeSpan(rtime, false)|safe }}
</a>
</li>
{% endfor %}