core: submissionPriority for rejudge

pull/311/head
undefined 3 years ago
parent 8223b45d23
commit 250ae863d0

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.5.6",
"version": "3.5.7",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",

@ -380,10 +380,13 @@ export class ProblemDetailHandler extends ProblemHandler {
async postRejudge(domainId: string, pid: number) {
this.checkPerm(PERM.PERM_REJUDGE_PROBLEM);
// TODO maybe async?
await record.getMulti(domainId, { pid }).forEach(async (doc) => {
await record.reset(domainId, doc._id, true);
await record.judge(domainId, doc._id, -50);
});
const rdocs = await record.getMulti(domainId, { pid, contest: { $ne: new ObjectID('0'.repeat(24)) } })
.project({ _id: 1 }).toArray();
const priority = await record.submissionPriority(this.user._id, -rdocs.length * 5 - 50);
await Promise.all(rdocs.map(
(doc) => record.reset(domainId, doc._id, true)
.then(() => record.judge(domainId, doc._id, priority)),
));
this.back();
}

@ -144,10 +144,11 @@ class RecordDetailHandler extends Handler {
@param('rid', Types.ObjectID)
async postRejudge(domainId: string, rid: ObjectID) {
this.checkPerm(PERM.PERM_REJUDGE);
const priority = await record.submissionPriority(this.user._id, -20);
const rdoc = await record.get(domainId, rid);
if (rdoc) {
await record.reset(domainId, rid, true);
await record.judge(domainId, rid, -10);
await record.judge(domainId, rid, priority);
}
this.back();
}

@ -3,7 +3,6 @@ const path = require('path');
const yaml = require('js-yaml');
const serialize = require('serialize-javascript');
const nunjucks = require('nunjucks');
const { filter } = require('lodash');
const jsesc = require('jsesc');
const argv = require('cac')().parse();
const { findFileSync } = require('@hydrooj/utils/lib/utils');

Loading…
Cancel
Save