mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core&ui: show history judge time
This commit is contained in:
1 parent
cd92a41090
commit
3c65c27911
2 files changed
+7
-6
No files matched your search
@@ -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 %}
|
||||
|
||||
Reference in new issue
Block a user