mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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
|
// eslint-disable-next-line consistent-return
|
||||||
async get(domainId: string, rid: ObjectId, download = false, rev?: ObjectId) {
|
async get(domainId: string, rid: ObjectId, download = false, rev?: ObjectId) {
|
||||||
let rdoc = this.rdoc;
|
let rdoc = this.rdoc;
|
||||||
const allRev: ObjectId[] = (await record.collHistory.find({ rid }).project({ _id: 1 }).toArray()).map((i) => i._id);
|
const allRev = await record.collHistory.find({ rid }).project({ _id: 1, judgeAt: 1 }).sort({ _id: -1 }).toArray();
|
||||||
if (rev && allRev.some((i) => i.equals(rev))) {
|
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']) };
|
rdoc = { ...rdoc, ...omit(await record.collHistory.findOne({ _id: rev }), ['_id']) };
|
||||||
}
|
}
|
||||||
let canViewDetail = true;
|
let canViewDetail = true;
|
||||||
@@ -203,7 +204,7 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
|
|||||||
} else if (download) return await this.download();
|
} else if (download) return await this.download();
|
||||||
this.response.template = 'record_detail.html';
|
this.response.template = 'record_detail.html';
|
||||||
this.response.body = {
|
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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if allRev|length %}
|
{% if allRevs|length %}
|
||||||
<div class="section side">
|
<div class="section side">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('History') }}</h1>
|
<h1 class="section__title">{{ _('History') }}</h1>
|
||||||
@@ -118,10 +118,10 @@
|
|||||||
{{ _('Latest Version') }}
|
{{ _('Latest Version') }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% for r in allRev %}
|
{% for r, rtime in allRevs %}
|
||||||
<li class="menu__item">
|
<li class="menu__item">
|
||||||
<a href="?rev={{ r }}" {% if rev and rev.equals(r) %}style="border-color: #4690d0;"{% endif %} class="menu__link">
|
<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>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
Reference in new issue
Block a user