mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
统一PostJudge接口
This commit is contained in:
1 parent
0ee306d0cf
commit
9efcdf9441
9 files changed
+108
-166
No files matched your search
+14
-8
@@ -11,6 +11,7 @@ import * as bus from '../service/bus';
|
||||
import {
|
||||
Route, Handler, Connection, ConnectionHandler, Types, param,
|
||||
} from '../service/server';
|
||||
import { Rdoc } from '../interface';
|
||||
|
||||
const RecordHandler = contest.ContestHandlerMixin(Handler);
|
||||
|
||||
@@ -117,8 +118,9 @@ class RecordMainConnectionHandler extends RecordConnectionHandler {
|
||||
|
||||
async message(msg) {
|
||||
if (msg.rids instanceof Array) {
|
||||
const rids = msg.rids.map((id: string) => new ObjectID(id));
|
||||
const rdocs = await record.getMulti(
|
||||
this.domainId, { _id: { $in: msg.rids.map((id) => new ObjectID(id)) } },
|
||||
this.domainId, { _id: { $in: rids } },
|
||||
).toArray();
|
||||
for (const rdoc of rdocs) {
|
||||
this.onRecordChange({ value: rdoc });
|
||||
@@ -131,7 +133,7 @@ class RecordMainConnectionHandler extends RecordConnectionHandler {
|
||||
}
|
||||
|
||||
async onRecordChange(data) {
|
||||
const rdoc = data.value;
|
||||
const rdoc: Rdoc = data.value.rdoc;
|
||||
if (rdoc.tid && rdoc.tid.toString() !== this.tid) return;
|
||||
// eslint-disable-next-line prefer-const
|
||||
let [udoc, pdoc] = await Promise.all([
|
||||
@@ -139,7 +141,7 @@ class RecordMainConnectionHandler extends RecordConnectionHandler {
|
||||
problem.get(this.domainId, rdoc.pid, null, false),
|
||||
]);
|
||||
if (pdoc && pdoc.hidden && !this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) pdoc = null;
|
||||
this.send({ html: await this.renderHTML('record_main_tr.html', { rdoc, udoc, pdoc }) });
|
||||
else this.send({ html: await this.renderHTML('record_main_tr.html', { rdoc, udoc, pdoc }) });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,12 +162,16 @@ class RecordDetailConnectionHandler extends contest.ContestHandlerMixin(Connecti
|
||||
}
|
||||
|
||||
async onRecordChange(data) {
|
||||
const rdoc = data.value;
|
||||
const rdoc: Rdoc = data.value.rdoc;
|
||||
const { $set, $push } = data.value;
|
||||
if (rdoc._id.toString() !== this.rid) return;
|
||||
this.send({
|
||||
status_html: await this.renderHTML('record_detail_status.html', { rdoc }),
|
||||
summary_html: await this.renderHTML('record_detail_summary.html', { rdoc }),
|
||||
});
|
||||
if ($set) this.send({ $set, $push });
|
||||
else {
|
||||
this.send({
|
||||
status_html: await this.renderHTML('record_detail_status.html', { rdoc }),
|
||||
summary_html: await this.renderHTML('record_detail_summary.html', { rdoc }),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async cleanup() {
|
||||
|
||||
Reference in new issue
Block a user