From b2ad3d2971c520e57850e4b8b6a25ec9c34a3f63 Mon Sep 17 00:00:00 2001 From: undefined Date: Sat, 11 Dec 2021 20:12:21 +0800 Subject: [PATCH] core: remove useless difficulty calculation --- packages/hydrooj/src/handler/judge.ts | 3 --- packages/hydrooj/src/handler/problem.ts | 1 - packages/hydrooj/src/model/problem.ts | 1 - packages/hydrooj/src/upgrade.ts | 6 ------ 4 files changed, 11 deletions(-) diff --git a/packages/hydrooj/src/handler/judge.ts b/packages/hydrooj/src/handler/judge.ts index 930a29f4..2130e4a2 100644 --- a/packages/hydrooj/src/handler/judge.ts +++ b/packages/hydrooj/src/handler/judge.ts @@ -1,6 +1,5 @@ import { ObjectID } from 'mongodb'; import { JudgeResultBody, RecordDoc, TestCase } from '../interface'; -import difficultyAlgorithm from '../lib/difficulty'; import { Logger } from '../logger'; import * as builtin from '../model/builtin'; import * as contest from '../model/contest'; @@ -34,9 +33,7 @@ export async function postJudge(rdoc: RecordDoc) { ? await problem.inc(rdoc.domainId, rdoc.pid, 'nAccept', 1) : await problem.get(rdoc.domainId, rdoc.pid); if (pdoc) { - const difficulty = difficultyAlgorithm(pdoc.nSubmit, pdoc.nAccept); await Promise.all([ - problem.edit(pdoc.domainId, pdoc.docId, { difficulty }), problem.inc(pdoc.domainId, pdoc.docId, `stats.${builtin.STATUS_SHORT_TEXTS[rdoc.status]}`, 1), problem.inc(pdoc.domainId, pdoc.docId, `stats.s${rdoc.score}`, 1), ]); diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 96a4038c..6a923065 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -14,7 +14,6 @@ import { ProblemConfig, ProblemDoc, ProblemStatusDoc, Tdoc, User, } from '../interface'; -import difficultyAlgorithm from '../lib/difficulty'; import paginate from '../lib/paginate'; import { isPid, parsePid as convertPid } from '../lib/validator'; import { PERM, PRIV } from '../model/builtin'; diff --git a/packages/hydrooj/src/model/problem.ts b/packages/hydrooj/src/model/problem.ts index 112ac0e3..9ccd03a2 100644 --- a/packages/hydrooj/src/model/problem.ts +++ b/packages/hydrooj/src/model/problem.ts @@ -8,7 +8,6 @@ import { ProblemNotFoundError, ValidationError } from '../error'; import type { Document, ProblemDict, ProblemStatusDoc, } from '../interface'; -import difficultyAlgorithm from '../lib/difficulty'; import { parseConfig } from '../lib/testdataConfig'; import * as bus from '../service/bus'; import { diff --git a/packages/hydrooj/src/upgrade.ts b/packages/hydrooj/src/upgrade.ts index 47f660d3..cc296f37 100644 --- a/packages/hydrooj/src/upgrade.ts +++ b/packages/hydrooj/src/upgrade.ts @@ -9,7 +9,6 @@ import { GridFSBucket, ObjectID } from 'mongodb'; import Queue from 'p-queue'; import { convertIniConfig } from '@hydrooj/utils/lib/cases'; import { buildContent } from './lib/content'; -import difficultyAlgorithm from './lib/difficulty'; import { size } from './lib/misc'; import { Logger } from './logger'; import { PRIV, STATUS } from './model/builtin'; @@ -199,11 +198,6 @@ const scripts: UpgradeScript[] = [ }, // Update problem difficulty async function _12_13() { - const _FRESH_INSTALL_IGNORE = 1; - await iterateAllProblem(['nSubmit', 'nAccept'], async (pdoc) => { - const difficulty = difficultyAlgorithm(pdoc.nSubmit, pdoc.nAccept); - await problem.edit(pdoc.domainId, pdoc.docId, { difficulty }); - }); return true; }, // Set domain owner perm