mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +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",
|
||||
"version": "2.13.48",
|
||||
"version": "2.13.49",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -230,7 +230,7 @@ export class ProblemDetailHandler extends ProblemHandler {
|
||||
// TODO maybe async?
|
||||
await record.getMulti(domainId, { pid }).forEach(async (doc) => {
|
||||
await record.reset(domainId, doc._id, true);
|
||||
await record.judge(domainId, doc._id);
|
||||
await record.judge(domainId, doc._id, -1);
|
||||
});
|
||||
this.back();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class RecordDetailHandler extends RecordHandler {
|
||||
const rdoc = await record.get(domainId, rid);
|
||||
if (rdoc) {
|
||||
await record.reset(domainId, rid, true);
|
||||
await record.judge(domainId, rid);
|
||||
await record.judge(domainId, rid, 0);
|
||||
}
|
||||
this.back();
|
||||
}
|
||||
@@ -165,7 +165,7 @@ class RecordRejudgeHandler extends Handler {
|
||||
const rdoc = await record.get(domainId, rid);
|
||||
if (rdoc) {
|
||||
await record.reset(domainId, rid, true);
|
||||
await record.judge(domainId, rid);
|
||||
await record.judge(domainId, rid, 0);
|
||||
}
|
||||
this.back();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export async function get(domainId: string, _id: ObjectID): Promise<Rdoc | 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);
|
||||
let config: RunConfig | ProblemConfig = rdoc.config;
|
||||
let data;
|
||||
@@ -66,6 +66,7 @@ export async function judge(domainId: string, rid: ObjectID) {
|
||||
delete rdoc._id;
|
||||
await task.add({
|
||||
...rdoc,
|
||||
priority,
|
||||
type: 'judge',
|
||||
rid,
|
||||
domainId,
|
||||
|
||||
@@ -10,8 +10,8 @@ const coll = db.collection('task');
|
||||
export async function add(task: Partial<Task> & { type: string }) {
|
||||
const t: Task = {
|
||||
...task,
|
||||
count: task.count || 1,
|
||||
priority: task.priority || 1,
|
||||
count: task.count ?? 1,
|
||||
priority: task.priority ?? 1,
|
||||
executeAfter: task.executeAfter || new Date(),
|
||||
_id: new ObjectID(),
|
||||
};
|
||||
@@ -34,7 +34,7 @@ export function del(_id: ObjectID) {
|
||||
export async function getFirst(query: FilterQuery<Task>) {
|
||||
const q = { ...query };
|
||||
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) {
|
||||
logger.debug('%o', res.value);
|
||||
if (res.value.interval) {
|
||||
|
||||
Reference in new issue
Block a user