mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: 评测队列优先级系统
This commit is contained in:
1 parent
5bdd77ca28
commit
1eb3e0797f
5 files changed
+9
-8
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.13.48",
|
"version": "2.13.49",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ export class ProblemDetailHandler extends ProblemHandler {
|
|||||||
// TODO maybe async?
|
// TODO maybe async?
|
||||||
await record.getMulti(domainId, { pid }).forEach(async (doc) => {
|
await record.getMulti(domainId, { pid }).forEach(async (doc) => {
|
||||||
await record.reset(domainId, doc._id, true);
|
await record.reset(domainId, doc._id, true);
|
||||||
await record.judge(domainId, doc._id);
|
await record.judge(domainId, doc._id, -1);
|
||||||
});
|
});
|
||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class RecordDetailHandler extends RecordHandler {
|
|||||||
const rdoc = await record.get(domainId, rid);
|
const rdoc = await record.get(domainId, rid);
|
||||||
if (rdoc) {
|
if (rdoc) {
|
||||||
await record.reset(domainId, rid, true);
|
await record.reset(domainId, rid, true);
|
||||||
await record.judge(domainId, rid);
|
await record.judge(domainId, rid, 0);
|
||||||
}
|
}
|
||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ class RecordRejudgeHandler extends Handler {
|
|||||||
const rdoc = await record.get(domainId, rid);
|
const rdoc = await record.get(domainId, rid);
|
||||||
if (rdoc) {
|
if (rdoc) {
|
||||||
await record.reset(domainId, rid, true);
|
await record.reset(domainId, rid, true);
|
||||||
await record.judge(domainId, rid);
|
await record.judge(domainId, rid, 0);
|
||||||
}
|
}
|
||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export async function get(domainId: string, _id: ObjectID): Promise<Rdoc | null>
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function judge(domainId: string, rid: ObjectID) {
|
export async function judge(domainId: string, rid: ObjectID, priority = 1) {
|
||||||
const rdoc = await get(domainId, rid);
|
const rdoc = await get(domainId, rid);
|
||||||
let config: RunConfig | ProblemConfig = rdoc.config;
|
let config: RunConfig | ProblemConfig = rdoc.config;
|
||||||
let data;
|
let data;
|
||||||
@@ -66,6 +66,7 @@ export async function judge(domainId: string, rid: ObjectID) {
|
|||||||
delete rdoc._id;
|
delete rdoc._id;
|
||||||
await task.add({
|
await task.add({
|
||||||
...rdoc,
|
...rdoc,
|
||||||
|
priority,
|
||||||
type: 'judge',
|
type: 'judge',
|
||||||
rid,
|
rid,
|
||||||
domainId,
|
domainId,
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ const coll = db.collection('task');
|
|||||||
export async function add(task: Partial<Task> & { type: string }) {
|
export async function add(task: Partial<Task> & { type: string }) {
|
||||||
const t: Task = {
|
const t: Task = {
|
||||||
...task,
|
...task,
|
||||||
count: task.count || 1,
|
count: task.count ?? 1,
|
||||||
priority: task.priority || 1,
|
priority: task.priority ?? 1,
|
||||||
executeAfter: task.executeAfter || new Date(),
|
executeAfter: task.executeAfter || new Date(),
|
||||||
_id: new ObjectID(),
|
_id: new ObjectID(),
|
||||||
};
|
};
|
||||||
@@ -34,7 +34,7 @@ export function del(_id: ObjectID) {
|
|||||||
export async function getFirst(query: FilterQuery<Task>) {
|
export async function getFirst(query: FilterQuery<Task>) {
|
||||||
const q = { ...query };
|
const q = { ...query };
|
||||||
q.executeAfter = q.executeAfter || { $lt: new Date() };
|
q.executeAfter = q.executeAfter || { $lt: new Date() };
|
||||||
const res = await coll.findOneAndDelete(q);
|
const res = await coll.findOneAndDelete(q, { sort: { priority: -1 } });
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
logger.debug('%o', res.value);
|
logger.debug('%o', res.value);
|
||||||
if (res.value.interval) {
|
if (res.value.interval) {
|
||||||
|
|||||||
Reference in new issue
Block a user