diff --git a/packages/better-search/package.json b/packages/better-search/package.json index 13b3e9acd..c1860f629 100644 --- a/packages/better-search/package.json +++ b/packages/better-search/package.json @@ -7,7 +7,7 @@ "author": "undefined ", "license": "AGPL-3.0-only", "dependencies": { - "nodejieba": "^2.4.2" + "nodejieba": "^2.5.1" }, "devDependencies": {}, "peerDependencies": { diff --git a/packages/hydrojudge/src/cases.ts b/packages/hydrojudge/src/cases.ts index bf7e5964c..8dc1d6f30 100644 --- a/packages/hydrojudge/src/cases.ts +++ b/packages/hydrojudge/src/cases.ts @@ -1,7 +1,7 @@ import fs from 'fs-extra'; import path from 'path'; import yaml from 'js-yaml'; -import { Dictionary } from 'lodash'; +import { Dictionary, sum } from 'lodash'; import { argv } from 'yargs'; import { FormatError, SystemError } from './error'; import { parseTimeMS, parseMemoryMB, ensureFile } from './utils'; @@ -285,11 +285,10 @@ function convertIniConfig(ini: string) { } function isValidConfig(config) { - if (config.count > (argv.max_testcases_count as string || 100)) throw new FormatError('Too many testcases. Cancelled.'); - let total_time = 0; - for (const subtask of config.subtasks) { - total_time += subtask.time_limit_ms * subtask.cases.length; + if (config.count > (argv.max_testcases_count as string || 100)) { + throw new FormatError('Too many testcases. Cancelled.'); } + const total_time = sum(config.subtasks.map((subtask) => subtask.time_limit_ms * subtask.cases.length)); if (total_time > (+argv.max_time_limit || 60) * 1000) { throw new FormatError('Total time limit longer than {0}s. Cancelled.', [+argv.max_time_limit || 60]); } diff --git a/packages/hydrooj/src/model/contest.ts b/packages/hydrooj/src/model/contest.ts index 264d310e2..96cff87a1 100644 --- a/packages/hydrooj/src/model/contest.ts +++ b/packages/hydrooj/src/model/contest.ts @@ -1,5 +1,4 @@ import { ObjectID, FilterQuery } from 'mongodb'; -import { filter, sortBy } from 'lodash'; import * as user from './user'; import * as problem from './problem'; import * as document from './document';