judge: use addProgress instead of progress

This commit is contained in:
undefined committed 2022-02-10 13:11:05 +08:00
1 parent 5182031bca
commit 8810ccd285
12 files changed
+20 -16

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"maxmind": "^4.3.4" "maxmind": "^4.3.5"
}, },
"preferUnplugged": true, "preferUnplugged": true,
"scripts": { "scripts": {
+3 -3
View File
@@ -1,13 +1,13 @@
{ {
"name": "@hydrooj/hydrojudge", "name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js", "bin": "bin/hydrojudge.js",
"version": "2.13.0", "version": "2.13.1",
"main": "package.json", "main": "package.json",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",
"dependencies": { "dependencies": {
"@hydrooj/utils": "workspace:*", "@hydrooj/utils": "workspace:*",
"axios": "^0.24.0", "axios": "^0.25.0",
"cac": "^6.7.12", "cac": "^6.7.12",
"esbuild": "0.14.3", "esbuild": "0.14.3",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
@@ -16,7 +16,7 @@
"mongodb": "^3.7.3", "mongodb": "^3.7.3",
"p-queue": "^7.2.0", "p-queue": "^7.2.0",
"shell-quote": "^1.7.3", "shell-quote": "^1.7.3",
"ws": "^8.4.2" "ws": "^8.5.0"
}, },
"preferUnplugged": true, "preferUnplugged": true,
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
+2 -2
View File
@@ -31,7 +31,7 @@ function judgeCase(c: Case, sid: string) {
memory_kb: 0, memory_kb: 0,
message: '', message: '',
}, },
progress: Math.floor((c.id * 100) / ctx.config.count), addProgress: 100 / ctx.config.count,
}, c.id); }, c.id);
return; return;
} }
@@ -103,7 +103,7 @@ function judgeCase(c: Case, sid: string) {
memory_kb: memory_usage_kb, memory_kb: memory_usage_kb,
message, message,
}, },
progress: Math.floor((c.id * 100) / ctx.config.count), addProgress: 100 / ctx.config.count,
}, c.id); }, c.id);
}; };
} }
@@ -9,6 +9,7 @@ export interface JudgeTaskInterface {
status?: number; status?: number;
message?: string; message?: string;
progress?: number; progress?: number;
addProgress?: number;
case?: { case?: {
status: number; status: number;
score?: number; score?: number;
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "3.4.14", "version": "3.4.15",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
+1 -1
View File
@@ -71,7 +71,7 @@ export async function next(body: JudgeResultBody) {
if (body.time !== undefined) $set.time = body.time; if (body.time !== undefined) $set.time = body.time;
if (body.memory !== undefined) $set.memory = body.memory; if (body.memory !== undefined) $set.memory = body.memory;
if (body.progress !== undefined) $set.progress = body.progress; if (body.progress !== undefined) $set.progress = body.progress;
rdoc = await record.update(rdoc.domainId, body.rid, $set, $push); rdoc = await record.update(rdoc.domainId, body.rid, $set, $push, {}, body.addProgress ? { progress: body.progress } : {});
bus.broadcast('record/change', rdoc!, $set, $push); bus.broadcast('record/change', rdoc!, $set, $push);
} }
+1
View File
@@ -521,6 +521,7 @@ export interface JudgeResultBody {
rid: ObjectID; rid: ObjectID;
judger?: number; judger?: number;
progress?: number; progress?: number;
addProgress?: number;
case?: { case?: {
id?: number; id?: number;
status: number; status: number;
+3 -1
View File
@@ -12,7 +12,7 @@ import {
} from '../interface'; } from '../interface';
import * as bus from '../service/bus'; import * as bus from '../service/bus';
import db from '../service/db'; import db from '../service/db';
import { MaybeArray } from '../typeutils'; import { MaybeArray, NumberKeys } from '../typeutils';
import { ArgMethod, buildProjection, Time } from '../utils'; import { ArgMethod, buildProjection, Time } from '../utils';
import { STATUS } from './builtin'; import { STATUS } from './builtin';
import problem from './problem'; import problem from './problem';
@@ -146,11 +146,13 @@ class RecordModel {
$set?: MatchKeysAndValues<RecordDoc>, $set?: MatchKeysAndValues<RecordDoc>,
$push?: PushOperator<RecordDoc>, $push?: PushOperator<RecordDoc>,
$unset?: OnlyFieldsOfType<RecordDoc, any, true | '' | 1>, $unset?: OnlyFieldsOfType<RecordDoc, any, true | '' | 1>,
$inc?: Partial<Record<NumberKeys<RecordDoc>, number>>,
): Promise<RecordDoc | null> { ): Promise<RecordDoc | null> {
const $update: UpdateQuery<RecordDoc> = {}; const $update: UpdateQuery<RecordDoc> = {};
if ($set && Object.keys($set).length) $update.$set = $set; if ($set && Object.keys($set).length) $update.$set = $set;
if ($push && Object.keys($push).length) $update.$push = $push; if ($push && Object.keys($push).length) $update.$push = $push;
if ($unset && Object.keys($unset).length) $update.$unset = $unset; if ($unset && Object.keys($unset).length) $update.$unset = $unset;
if ($inc && Object.keys($inc).length) $update.$inc = $inc;
if (_id instanceof Array) { if (_id instanceof Array) {
await RecordModel.coll.updateMany({ _id: { $in: _id }, domainId }, $update); await RecordModel.coll.updateMany({ _id: { $in: _id }, domainId }, $update);
return null; return null;
+1 -1
View File
@@ -11,7 +11,7 @@
"build": "tsc" "build": "tsc"
}, },
"devDependencies": { "devDependencies": {
"@types/mysql": "^2.15.20" "@types/mysql": "^2.15.21"
}, },
"dependencies": { "dependencies": {
"@hydrooj/utils": "workspace:*", "@hydrooj/utils": "workspace:*",
+4 -4
View File
@@ -10,7 +10,7 @@
"lint": "eslint ." "lint": "eslint ."
}, },
"devDependencies": { "devDependencies": {
"@blueprintjs/core": "^3.52.0", "@blueprintjs/core": "^3.53.0",
"@hydrooj/utils": "workspace:*", "@hydrooj/utils": "workspace:*",
"@types/gulp-if": "^0.0.34", "@types/gulp-if": "^0.0.34",
"@types/jquery": "^3.5.13", "@types/jquery": "^3.5.13",
@@ -25,7 +25,7 @@
"chalk": "^4.1.2", "chalk": "^4.1.2",
"classnames": "^2.3.1", "classnames": "^2.3.1",
"clean-webpack-plugin": "^4.0.0", "clean-webpack-plugin": "^4.0.0",
"clipboard": "^2.0.9", "clipboard": "^2.0.10",
"copy-webpack-plugin": "^6.4.1", "copy-webpack-plugin": "^6.4.1",
"css-loader": "^4.3.0", "css-loader": "^4.3.0",
"diff-dom": "^4.2.3", "diff-dom": "^4.2.3",
@@ -42,7 +42,7 @@
"fancy-log": "^1.3.3", "fancy-log": "^1.3.3",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"friendly-errors-webpack-plugin": "^1.7.0", "friendly-errors-webpack-plugin": "^1.7.0",
"graphiql": "^1.5.16", "graphiql": "^1.5.17",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-cli": "^2.3.0", "gulp-cli": "^2.3.0",
"gulp-iconfont": "^11.0.1", "gulp-iconfont": "^11.0.1",
@@ -117,7 +117,7 @@
"markdown-it-table-of-contents": "^0.6.0", "markdown-it-table-of-contents": "^0.6.0",
"mongodb": "^3.7.3", "mongodb": "^3.7.3",
"nunjucks": "^3.2.3", "nunjucks": "^3.2.3",
"react-query": "^3.34.12", "react-query": "^3.34.14",
"streamsaver": "^2.0.5", "streamsaver": "^2.0.5",
"xss": "^1.0.10" "xss": "^1.0.10"
} }
+1 -1
View File
@@ -12,7 +12,7 @@
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"moment": "^2.29.1", "moment": "^2.29.1",
"mongodb": "^3.7.3", "mongodb": "^3.7.3",
"systeminformation": "^5.11.0" "systeminformation": "^5.11.2"
}, },
"devDependencies": { "devDependencies": {
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
+1 -1
View File
@@ -12,7 +12,7 @@
"chrome-finder": "^1.0.7", "chrome-finder": "^1.0.7",
"jsdom": "^19.0.0", "jsdom": "^19.0.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"puppeteer-core": "^13.1.3", "puppeteer-core": "^13.2.0",
"puppeteer-extra": "^3.2.3", "puppeteer-extra": "^3.2.3",
"puppeteer-extra-plugin-portal": "^3.0.1", "puppeteer-extra-plugin-portal": "^3.0.1",
"puppeteer-extra-plugin-stealth": "^2.9.0", "puppeteer-extra-plugin-stealth": "^2.9.0",