mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: display fix
This commit is contained in:
6 files changed
+57
-22
No files matched your search
Vendored
+1
@@ -4,6 +4,7 @@
|
||||
"files.eol": "\n",
|
||||
"editor.detectIndentation": true,
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"typescript.tsserver.maxTsServerMemory": 16384,
|
||||
"[json]": {
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": false
|
||||
|
||||
@@ -256,20 +256,26 @@ export default class RecordModel {
|
||||
|
||||
export function apply(ctx: Context) {
|
||||
// Mark problem as deleted
|
||||
ctx.on('problem/delete', (domainId, docId) => RecordModel.coll.deleteMany({ domainId, pid: docId }));
|
||||
ctx.on('problem/delete', (domainId, docId) => Promise.all([
|
||||
RecordModel.coll.deleteMany({ domainId, pid: docId }),
|
||||
RecordModel.collStat.deleteMany({ domainId, pid: docId }),
|
||||
]));
|
||||
ctx.on('domain/delete', (domainId) => RecordModel.coll.deleteMany({ domainId }));
|
||||
ctx.on('record/judge', (rdoc, updated) => {
|
||||
if (rdoc.status === STATUS.STATUS_ACCEPTED && updated) {
|
||||
RecordModel.collStat.insertOne({
|
||||
ctx.on('record/judge', async (rdoc, updated) => {
|
||||
if (rdoc.status === STATUS.STATUS_ACCEPTED && updated && !rdoc.contest) {
|
||||
await RecordModel.collStat.updateOne({
|
||||
_id: rdoc._id,
|
||||
domainId: rdoc.domainId,
|
||||
pid: rdoc.pid,
|
||||
uid: rdoc.uid,
|
||||
time: rdoc.time,
|
||||
memory: rdoc.memory,
|
||||
length: rdoc.code?.length || 0,
|
||||
lang: rdoc.lang,
|
||||
});
|
||||
}, {
|
||||
$set: {
|
||||
domainId: rdoc.domainId,
|
||||
pid: rdoc.pid,
|
||||
uid: rdoc.uid,
|
||||
time: rdoc.time,
|
||||
memory: rdoc.memory,
|
||||
length: rdoc.code?.length || 0,
|
||||
lang: rdoc.lang,
|
||||
},
|
||||
}, { upsert: true });
|
||||
}
|
||||
});
|
||||
ctx.on('ready', async () => {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import moment from 'moment-timezone';
|
||||
import { Filter, ObjectId } from 'mongodb';
|
||||
import { Time } from '@hydrooj/utils';
|
||||
import { STATUS } from '@hydrooj/utils/lib/status';
|
||||
import { Context } from '../context';
|
||||
import { Schedule } from '../interface';
|
||||
import { Logger } from '../logger';
|
||||
import { ContestModel, DocumentModel } from '../plugin-api';
|
||||
import db from '../service/db';
|
||||
import type { WorkerService } from '../service/worker';
|
||||
import RecordModel from './record';
|
||||
@@ -64,6 +67,29 @@ export async function apply(ctx: Context) {
|
||||
ScheduleModel.Worker = c.worker;
|
||||
c.worker.addHandler('task.daily', async () => {
|
||||
await RecordModel.coll.deleteMany({ contest: { $in: [RecordModel.RECORD_PRETEST, RecordModel.RECORD_GENERATE] } });
|
||||
const tdocs = await db.collection('document').find({
|
||||
docType: DocumentModel.TYPE_CONTEST,
|
||||
endAt: { $gt: new Date(Date.now() - 2 * Time.day) },
|
||||
}).project({ docId: 1, beginAt: 1 }).toArray();
|
||||
const first = Math.min(...tdocs.map((i) => i.beginAt.getTime()));
|
||||
const bulk = RecordModel.collStat.initializeUnorderedBulkOp();
|
||||
const cursor = RecordModel.coll.find({
|
||||
status: STATUS.STATUS_ACCEPTED,
|
||||
contest: { $in: tdocs.map((i) => i.docId) },
|
||||
_id: { $gt: Time.getObjectID(new Date(first)) },
|
||||
});
|
||||
for await (const rdoc of cursor) {
|
||||
bulk.find({ _id: rdoc._id }).upsert().updateOne({
|
||||
domainId: rdoc.domainId,
|
||||
pid: rdoc.pid,
|
||||
uid: rdoc.uid,
|
||||
time: rdoc.time,
|
||||
memory: rdoc.memory,
|
||||
length: rdoc.code?.length || 0,
|
||||
lang: rdoc.lang,
|
||||
});
|
||||
}
|
||||
await bulk.execute();
|
||||
await global.Hydro.script.rp?.run({}, new Logger('task/rp').debug);
|
||||
await global.Hydro.script.problemStat?.run({}, new Logger('task/problem').debug);
|
||||
if (global.Hydro.model.system.get('server.checkUpdate') && !(new Date().getDay() % 3)) {
|
||||
|
||||
@@ -650,11 +650,13 @@ const scripts: UpgradeScript[] = [
|
||||
});
|
||||
},
|
||||
async function _88_89() {
|
||||
const cursor = RecordModel.getMulti(undefined, { status: STATUS.STATUS_ACCEPTED });
|
||||
let bulk = [];
|
||||
const cursor = RecordModel.getMulti(undefined, {
|
||||
status: STATUS.STATUS_ACCEPTED,
|
||||
contest: { $nin: [RecordModel.RECORD_PRETEST, RecordModel.RECORD_GENERATE] },
|
||||
});
|
||||
let bulk = RecordModel.collStat.initializeUnorderedBulkOp();
|
||||
for await (const doc of cursor) {
|
||||
bulk.push({
|
||||
_id: doc._id,
|
||||
bulk.find({ _id: doc._id }).upsert().updateOne({
|
||||
domainId: doc.domainId,
|
||||
pid: doc.pid,
|
||||
uid: doc.uid,
|
||||
@@ -663,12 +665,12 @@ const scripts: UpgradeScript[] = [
|
||||
length: doc.code?.length || 0,
|
||||
lang: doc.lang,
|
||||
});
|
||||
if (bulk.length > 500) {
|
||||
await RecordModel.collStat.insertMany(bulk);
|
||||
bulk = [];
|
||||
if (bulk.batches.length > 500) {
|
||||
await bulk.execute();
|
||||
bulk = RecordModel.collStat.initializeUnorderedBulkOp();
|
||||
}
|
||||
}
|
||||
if (bulk.length) await RecordModel.collStat.insertMany(bulk);
|
||||
if (bulk.batches.length) await bulk.execute();
|
||||
return true;
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.50.0",
|
||||
"version": "4.50.1",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "index.ts",
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
<td class="col--time">{% if rsdoc['time'] %}{% if [STATUS.STATUS_TIME_LIMIT_EXCEEDED, STATUS.STATUS_MEMORY_LIMIT_EXCEEDED, STATUS.STATUS_OUTPUT_LIMIT_EXCEEDED].includes(rsdoc['status']) %}≥{% endif %}{{ rsdoc.time|round|int }}ms{% else %}-{% endif %}</td>
|
||||
<td class="col--memory">{% if rsdoc['memory'] %}{% if [STATUS.STATUS_TIME_LIMIT_EXCEEDED, STATUS.STATUS_MEMORY_LIMIT_EXCEEDED, STATUS.STATUS_OUTPUT_LIMIT_EXCEEDED].includes(rsdoc['status']) %}≥{% endif %}{{ size(rsdoc.memory, 1024) }}{% else %}-{% endif %}</td>
|
||||
<td class="col--lang">{{ model.setting.langs[rsdoc['lang']].display }}</td>
|
||||
<td class="col--code">{{ size(rsdoc.code) }}</td>
|
||||
<td class="col--code">{{ size(rsdoc.length) }}</td>
|
||||
<td class="col--submit-at">{{ datetimeSpan(rsdoc['_id'], false)|safe }}</td>
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
|
||||
Reference in new issue
Block a user