mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
🆕 系统状态,修复题目复制
This commit is contained in:
1 parent
933dc73162
commit
3cb4d2ad49
19 files changed
+66
-29
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"version": "2.0.1",
|
"version": "2.0.2",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "masnn",
|
"author": "masnn",
|
||||||
"os": [
|
"os": [
|
||||||
|
|||||||
@@ -102,14 +102,13 @@ async function postInit() {
|
|||||||
data.rid = new ObjectID(that.rid);
|
data.rid = new ObjectID(that.rid);
|
||||||
data.time = data.time_ms || data.time;
|
data.time = data.time_ms || data.time;
|
||||||
data.memory = data.memory_kb || data.memory;
|
data.memory = data.memory_kb || data.memory;
|
||||||
data.message = data.judge_text || data.message;
|
|
||||||
data.compilerText = data.compiler_text || data.compilerText;
|
data.compilerText = data.compiler_text || data.compilerText;
|
||||||
if (data.case) {
|
if (data.case) {
|
||||||
data.case = {
|
data.case = {
|
||||||
status: data.case.status,
|
status: data.case.status,
|
||||||
time: data.case.time_ms || data.case.time,
|
time: data.case.time_ms || data.case.time,
|
||||||
memory: data.case.memory_kb || data.case.memory,
|
memory: data.case.memory_kb || data.case.memory,
|
||||||
message: data.judge_text || data.message || data.judgeText,
|
message: data.message || data.judgeText,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (id) {
|
if (id) {
|
||||||
@@ -213,13 +212,13 @@ async function postInit() {
|
|||||||
status: STATUS_COMPILE_ERROR, score: 0, time_ms: 0, memory_kb: 0,
|
status: STATUS_COMPILE_ERROR, score: 0, time_ms: 0, memory_kb: 0,
|
||||||
});
|
});
|
||||||
} else if (e instanceof FormatError) {
|
} else if (e instanceof FormatError) {
|
||||||
this.next({ judge_text: `${e.message}\n${JSON.stringify(e.params)}` });
|
this.next({ message: `${e.message}\n${JSON.stringify(e.params)}` });
|
||||||
this.end({
|
this.end({
|
||||||
status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0,
|
status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
this.next({ judge_text: `${e.message}\n${e.stack}\n${JSON.stringify(e.params)}` });
|
this.next({ message: `${e.message}\n${e.stack}\n${JSON.stringify(e.params)}` });
|
||||||
this.end({
|
this.end({
|
||||||
status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0,
|
status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ async function readAutoCases(folder, { next }) {
|
|||||||
let result = await read0(folder, files, checkFile);
|
let result = await read0(folder, files, checkFile);
|
||||||
if (!result.count) result = await read1(folder, files, checkFile);
|
if (!result.count) result = await read1(folder, files, checkFile);
|
||||||
Object.assign(config, result);
|
Object.assign(config, result);
|
||||||
next({ judge_text: `识别到${config.count}个测试点` });
|
next({ message: `识别到${config.count}个测试点` });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new SystemError('在自动识别测试点的过程中出现了错误。', [e]);
|
throw new SystemError('在自动识别测试点的过程中出现了错误。', [e]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ function judgeCase(c) {
|
|||||||
score: 0,
|
score: 0,
|
||||||
time_ms: time_usage_ms,
|
time_ms: time_usage_ms,
|
||||||
memory_kb: memory_usage_kb,
|
memory_kb: memory_usage_kb,
|
||||||
judge_text: message,
|
message,
|
||||||
},
|
},
|
||||||
progress: Math.floor((c.id * 100) / ctx.config.count),
|
progress: Math.floor((c.id * 100) / ctx.config.count),
|
||||||
}, c.id);
|
}, c.id);
|
||||||
@@ -144,7 +144,7 @@ export const judge = async (ctx) => {
|
|||||||
for (const sid in ctx.config.subtasks) tasks.push(judgeSubtask(ctx.config.subtasks[sid])(ctx));
|
for (const sid in ctx.config.subtasks) tasks.push(judgeSubtask(ctx.config.subtasks[sid])(ctx));
|
||||||
await Promise.all(tasks);
|
await Promise.all(tasks);
|
||||||
ctx.stat.done = new Date();
|
ctx.stat.done = new Date();
|
||||||
ctx.next({ judge_text: JSON.stringify(ctx.stat) });
|
ctx.next({ message: JSON.stringify(ctx.stat) });
|
||||||
ctx.end({
|
ctx.end({
|
||||||
status: ctx.total_status,
|
status: ctx.total_status,
|
||||||
score: ctx.total_score,
|
score: ctx.total_score,
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function judgeCase(c) {
|
|||||||
score: 0,
|
score: 0,
|
||||||
time_ms: time_usage_ms,
|
time_ms: time_usage_ms,
|
||||||
memory_kb: memory_usage_kb,
|
memory_kb: memory_usage_kb,
|
||||||
judge_text: message,
|
message,
|
||||||
},
|
},
|
||||||
progress: Math.floor((c.id * 100) / ctx.config.count),
|
progress: Math.floor((c.id * 100) / ctx.config.count),
|
||||||
});
|
});
|
||||||
@@ -110,7 +110,7 @@ export const judge = async (ctx) => {
|
|||||||
}
|
}
|
||||||
await Promise.all(tasks);
|
await Promise.all(tasks);
|
||||||
ctx.stat.done = new Date();
|
ctx.stat.done = new Date();
|
||||||
ctx.next({ judge_text: JSON.stringify(ctx.stat) });
|
ctx.next({ message: JSON.stringify(ctx.stat) });
|
||||||
console.log({
|
console.log({
|
||||||
status: ctx.total_status,
|
status: ctx.total_status,
|
||||||
score: ctx.total_score,
|
score: ctx.total_score,
|
||||||
|
|||||||
@@ -48,11 +48,11 @@ export const judge = async (ctx) => {
|
|||||||
status,
|
status,
|
||||||
time_ms: time_usage_ms,
|
time_ms: time_usage_ms,
|
||||||
memory_kb: memory_usage_kb,
|
memory_kb: memory_usage_kb,
|
||||||
judge_text: message,
|
message,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
ctx.stat.done = new Date();
|
ctx.stat.done = new Date();
|
||||||
ctx.next({ judge_text: JSON.stringify(ctx.stat) });
|
ctx.next({ message: JSON.stringify(ctx.stat) });
|
||||||
ctx.end({
|
ctx.end({
|
||||||
status,
|
status,
|
||||||
score: status === STATUS.STATUS_ACCEPTED ? 100 : 0,
|
score: status === STATUS.STATUS_ACCEPTED ? 100 : 0,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export async function judge({
|
|||||||
status,
|
status,
|
||||||
progress: 100,
|
progress: 100,
|
||||||
case: {
|
case: {
|
||||||
status, score, time_ms: 0, memory_kb: 0, judge_text: message,
|
status, score, time_ms: 0, memory_kb: 0, message,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
end({
|
end({
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ export async function del(fileId) {
|
|||||||
|
|
||||||
export async function run(execute, params?) {
|
export async function run(execute, params?) {
|
||||||
let result;
|
let result;
|
||||||
|
global.reqCount++;
|
||||||
// eslint-disable-next-line no-return-await
|
// eslint-disable-next-line no-return-await
|
||||||
if (typeof execute === 'object') return await runMultiple(execute);
|
if (typeof execute === 'object') return await runMultiple(execute);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ int main(){
|
|||||||
},
|
},
|
||||||
stat: {},
|
stat: {},
|
||||||
clean: [],
|
clean: [],
|
||||||
next: () => { },
|
next: (data) => {
|
||||||
end: (data) => {
|
if (data.case) output = data.case.message;
|
||||||
if (data.stdout) output = data.stdout;
|
|
||||||
},
|
},
|
||||||
|
end: () => { },
|
||||||
};
|
};
|
||||||
context.tmpdir = path.resolve(tmpdir(), 'hydro', 'tmp', 'sysinfo');
|
context.tmpdir = path.resolve(tmpdir(), 'hydro', 'tmp', 'sysinfo');
|
||||||
fs.ensureDirSync(context.tmpdir);
|
fs.ensureDirSync(context.tmpdir);
|
||||||
@@ -52,7 +52,7 @@ int main(){
|
|||||||
tmpfs.umount(context.tmpdir);
|
tmpfs.umount(context.tmpdir);
|
||||||
fs.removeSync(context.tmpdir);
|
fs.removeSync(context.tmpdir);
|
||||||
const a = output.split(' ');
|
const a = output.split(' ');
|
||||||
return parseInt(a[a.length - 1], 10);
|
return parseInt(a[a.length - 2], 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get() {
|
export async function get() {
|
||||||
@@ -84,11 +84,20 @@ export async function get() {
|
|||||||
cache.flags = flags;
|
cache.flags = flags;
|
||||||
cache.mid = mid;
|
cache.mid = mid;
|
||||||
cache.stack = stack;
|
cache.stack = stack;
|
||||||
|
global.reqCount = 0;
|
||||||
return {
|
return {
|
||||||
mid, cpu, memory, osinfo, load, flags, CpuTemp, battery, stack,
|
mid, cpu, memory, osinfo, load, flags, CpuTemp, battery, stack, reqCount: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace NodeJS {
|
||||||
|
interface Global {
|
||||||
|
reqCount: number,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function update() {
|
export async function update() {
|
||||||
const [Memory, CurrentLoad, CpuTemp, Battery] = await Promise.all([
|
const [Memory, CurrentLoad, CpuTemp, Battery] = await Promise.all([
|
||||||
systeminformation.mem(),
|
systeminformation.mem(),
|
||||||
@@ -104,13 +113,15 @@ export async function update() {
|
|||||||
let battery;
|
let battery;
|
||||||
if (!Battery.hasbattery) battery = 'No battery';
|
if (!Battery.hasbattery) battery = 'No battery';
|
||||||
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.ischarging ? ' Charging' : ''}`;
|
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.ischarging ? ' Charging' : ''}`;
|
||||||
|
const reqCount = global.reqCount;
|
||||||
|
global.reqCount = 0;
|
||||||
return [
|
return [
|
||||||
mid,
|
mid,
|
||||||
{
|
{
|
||||||
memory, load, battery, CpuTemp,
|
memory, load, battery, CpuTemp, reqCount,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
mid, cpu, memory, osinfo, load, flags, battery, CpuTemp, stack,
|
mid, cpu, memory, osinfo, load, flags, battery, CpuTemp, stack, reqCount,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -646,6 +646,7 @@ Star: 收藏
|
|||||||
Start at: 开始于
|
Start at: 开始于
|
||||||
Statistics: 统计
|
Statistics: 统计
|
||||||
Status is hidden: 状态已隐藏
|
Status is hidden: 状态已隐藏
|
||||||
|
status: 状态
|
||||||
Status: 状态
|
Status: 状态
|
||||||
Submission Statistics: 递交统计
|
Submission Statistics: 递交统计
|
||||||
Submission: 递交
|
Submission: 递交
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.12.8",
|
"version": "2.12.9",
|
||||||
"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",
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export async function load(call: Entry) {
|
|||||||
bus.subscribe(['system_database_connected'], h);
|
bus.subscribe(['system_database_connected'], h);
|
||||||
require('../service/db');
|
require('../service/db');
|
||||||
});
|
});
|
||||||
|
require('../service/monitor');
|
||||||
for (const i of builtinModel) require(`../model/${i}`);
|
for (const i of builtinModel) require(`../model/${i}`);
|
||||||
const modelSystem = require('../model/system');
|
const modelSystem = require('../model/system');
|
||||||
const dbVer = await modelSystem.get('db.ver');
|
const dbVer = await modelSystem.get('db.ver');
|
||||||
|
|||||||
@@ -199,6 +199,11 @@ class DomainJoinApplicationsHandler extends ManageHandler {
|
|||||||
if (!this.response.body.joinSettings) {
|
if (!this.response.body.joinSettings) {
|
||||||
delete this.response.body.expirations[domain.JOIN_EXPIRATION_KEEP_CURRENT];
|
delete this.response.body.expirations[domain.JOIN_EXPIRATION_KEEP_CURRENT];
|
||||||
}
|
}
|
||||||
|
this.response.body.path = [
|
||||||
|
['Hydro', 'homepage'],
|
||||||
|
['domain', null],
|
||||||
|
['domain_join_applications', null],
|
||||||
|
];
|
||||||
this.response.template = 'domain_join_applications.html';
|
this.response.template = 'domain_join_applications.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class ProblemMainHandler extends ProblemHandler {
|
|||||||
}
|
}
|
||||||
if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) query.hidden = false;
|
if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) query.hidden = false;
|
||||||
const [pdocs, ppcount, pcount] = await paginate(
|
const [pdocs, ppcount, pcount] = await paginate(
|
||||||
problem.getMulti(domainId, query).sort({ pid: 1 }),
|
problem.getMulti(domainId, query).sort({ pid: 1, docId: 1 }),
|
||||||
page,
|
page,
|
||||||
CONSTANT.PROBLEM_PER_PAGE,
|
CONSTANT.PROBLEM_PER_PAGE,
|
||||||
);
|
);
|
||||||
@@ -119,7 +119,7 @@ class ProblemCategoryHandler extends ProblemHandler {
|
|||||||
let psdict = {};
|
let psdict = {};
|
||||||
if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) q.hidden = false;
|
if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) q.hidden = false;
|
||||||
const [pdocs, ppcount, pcount] = await paginate(
|
const [pdocs, ppcount, pcount] = await paginate(
|
||||||
problem.getMulti(domainId, q).sort({ pid: 1 }),
|
problem.getMulti(domainId, q).sort({ pid: 1, docId: 1 }),
|
||||||
page,
|
page,
|
||||||
CONSTANT.PROBLEM_PER_PAGE,
|
CONSTANT.PROBLEM_PER_PAGE,
|
||||||
);
|
);
|
||||||
@@ -190,7 +190,7 @@ class ProblemDetailHandler extends ProblemHandler {
|
|||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
async get(...args: any[]) { }
|
async get(...args: any[]) { }
|
||||||
|
|
||||||
@param('pid', Types.ObjectID)
|
@param('pid', Types.UnsignedInt)
|
||||||
@param('dest', Types.String)
|
@param('dest', Types.String)
|
||||||
@param('hidden', Types.Boolean)
|
@param('hidden', Types.Boolean)
|
||||||
async postCopy(domainId: string, pid: number, destDomainId: string, hidden = false) {
|
async postCopy(domainId: string, pid: number, destDomainId: string, hidden = false) {
|
||||||
|
|||||||
@@ -192,7 +192,6 @@ PERM.PERM_DEFAULT = PERM.PERM_VIEW
|
|||||||
| PERM.PERM_EDIT_DISCUSSION_SELF
|
| PERM.PERM_EDIT_DISCUSSION_SELF
|
||||||
| PERM.PERM_REPLY_DISCUSSION
|
| PERM.PERM_REPLY_DISCUSSION
|
||||||
| PERM.PERM_EDIT_DISCUSSION_REPLY_SELF
|
| PERM.PERM_EDIT_DISCUSSION_REPLY_SELF
|
||||||
// PERM_EDIT_DISCUSSION_REPLY_SELF_DISCUSSION
|
|
||||||
| PERM.PERM_DELETE_DISCUSSION_REPLY_SELF
|
| PERM.PERM_DELETE_DISCUSSION_REPLY_SELF
|
||||||
| PERM.PERM_DELETE_DISCUSSION_REPLY_SELF_DISCUSSION
|
| PERM.PERM_DELETE_DISCUSSION_REPLY_SELF_DISCUSSION
|
||||||
| PERM.PERM_VIEW_CONTEST
|
| PERM.PERM_VIEW_CONTEST
|
||||||
@@ -206,7 +205,6 @@ PERM.PERM_DEFAULT = PERM.PERM_VIEW
|
|||||||
| PERM.PERM_VIEW_TRAINING
|
| PERM.PERM_VIEW_TRAINING
|
||||||
| PERM.PERM_CREATE_TRAINING
|
| PERM.PERM_CREATE_TRAINING
|
||||||
| PERM.PERM_EDIT_TRAINING_SELF
|
| PERM.PERM_EDIT_TRAINING_SELF
|
||||||
| PERM.PERM_VIEW_RANKING
|
|
||||||
| PERM.PERM_SUBMIT_PROBLEM
|
| PERM.PERM_SUBMIT_PROBLEM
|
||||||
| PERM.PERM_CREATE_PROBLEM_SOLUTION
|
| PERM.PERM_CREATE_PROBLEM_SOLUTION
|
||||||
| PERM.PERM_VOTE_PROBLEM_SOLUTION
|
| PERM.PERM_VOTE_PROBLEM_SOLUTION
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export function updateJudger(args) {
|
|||||||
args.type = 'judger';
|
args.type = 'judger';
|
||||||
return coll.updateOne(
|
return coll.updateOne(
|
||||||
{ mid: args.mid, type: 'judger' },
|
{ mid: args.mid, type: 'judger' },
|
||||||
{ $set: args },
|
{ $set: { ...args, updateAt: new Date() } },
|
||||||
{ upsert: true },
|
{ upsert: true },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -326,6 +326,7 @@ export class Handler {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.message);
|
console.error(e.message);
|
||||||
console.log(name, args);
|
console.log(name, args);
|
||||||
|
console.log(e.stack);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/migrate-vijos",
|
"name": "@hydrooj/migrate-vijos",
|
||||||
"version": "1.3.3",
|
"version": "1.3.4",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"repository": "git@github.com:hydro-dev/Hydro.git",
|
"repository": "git@github.com:hydro-dev/Hydro.git",
|
||||||
"author": "undefined <masnn0@outlook.com>",
|
"author": "undefined <masnn0@outlook.com>",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import mongodb, { ObjectID, Db, Cursor } from 'mongodb';
|
|||||||
const dst = global.Hydro.service.db;
|
const dst = global.Hydro.service.db;
|
||||||
const { file, discussion, document } = global.Hydro.model;
|
const { file, discussion, document } = global.Hydro.model;
|
||||||
const { testdataConfig } = global.Hydro.lib;
|
const { testdataConfig } = global.Hydro.lib;
|
||||||
|
// TODO handle usage_userfile
|
||||||
// TODO output enhancement
|
// TODO output enhancement
|
||||||
const map = {};
|
const map = {};
|
||||||
|
|
||||||
@@ -398,6 +398,25 @@ async function message(src: Db, report: Function) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function removeInvalidPid(src: Db, report: Function) {
|
||||||
|
const count = await dst.collection('document').find({ docType: 10 }).count();
|
||||||
|
const bulk = dst.collection('document').initializeUnorderedBulkOp();
|
||||||
|
await report({ progress: 1, message: `Remove pid: ${count}` });
|
||||||
|
const total = Math.floor(count / 50);
|
||||||
|
for (let i = 0; i <= total; i++) {
|
||||||
|
const docs = await dst.collection('document')
|
||||||
|
.find({ docType: 10 }).skip(i * 50).limit(50)
|
||||||
|
.toArray();
|
||||||
|
for (const doc of docs) {
|
||||||
|
const id = parseInt(doc.pid, 10);
|
||||||
|
if (Number.isSafeInteger(id)) {
|
||||||
|
bulk.find({ _id: doc._id }).updateOne({ $unset: { pid: '' } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await bulk.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function task(name: string, src: Db, report: Function) {
|
async function task(name: string, src: Db, report: Function) {
|
||||||
const count = await cursor[name](src).count();
|
const count = await cursor[name](src).count();
|
||||||
await report({ progress: 1, message: `${name}: ${count}` });
|
await report({ progress: 1, message: `${name}: ${count}` });
|
||||||
@@ -513,6 +532,7 @@ export async function run({
|
|||||||
await fixProblem(report);
|
await fixProblem(report);
|
||||||
await discussionNode(src, report);
|
await discussionNode(src, report);
|
||||||
await message(src, report);
|
await message(src, report);
|
||||||
|
await removeInvalidPid(src, report);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user