mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: 计量尝试人数而非提交量
suggested by @Menci
This commit is contained in:
1 parent
e5d715d02b
commit
e49ffa9f7b
17 files changed
+102
-138
No files matched your search
@@ -353,10 +353,12 @@ export class ContestDetailProblemSubmitHandler extends ContestProblemHandler {
|
||||
type: document.TYPE_CONTEST,
|
||||
tid,
|
||||
});
|
||||
const pdomainId = typeof pid === 'string' ? pid.split(':')[0] : domainId;
|
||||
const ppid = typeof pid === 'number' ? pid : +pid.split(':')[1];
|
||||
const rdoc = await record.get(domainId, rid);
|
||||
if (!pretest) {
|
||||
await Promise.all([
|
||||
problem.inc(domainId, pid, 'nSubmit', 1),
|
||||
(this.tsdoc.journal || []).filter((i) => i.pid === pid).length ? Promise.resolve() : problem.inc(pdomainId, ppid, 'nSubmit', 1),
|
||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
||||
contest.updateStatus(domainId, tid, this.user._id, rid, pid),
|
||||
]);
|
||||
|
||||
@@ -233,7 +233,7 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
|
||||
const rdoc = await record.get(domainId, rid);
|
||||
if (pretest) {
|
||||
await Promise.all([
|
||||
problem.inc(pdomainId, ppid, 'nSubmit', 1),
|
||||
(this.tsdoc.journal || []).filter((i) => i.pid === pid).length ? Promise.resolve() : problem.inc(pdomainId, ppid, 'nSubmit', 1),
|
||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
||||
contest.updateStatus(domainId, tid, this.user._id,
|
||||
rid, pid, false, 0, document.TYPE_HOMEWORK),
|
||||
|
||||
@@ -35,9 +35,7 @@ export async function postJudge(rdoc: RecordDoc) {
|
||||
? await problem.inc(rdoc.pdomain, rdoc.pid, 'nAccept', 1)
|
||||
: await problem.get(rdoc.pdomain, rdoc.pid);
|
||||
const difficulty = difficultyAlgorithm(pdoc.nSubmit, pdoc.nAccept);
|
||||
if (!updated) await record.updateMulti(rdoc.domainId, { uid: rdoc.uid, status: builtin.STATUS.STATUS_ACCEPTED }, { effective: false });
|
||||
await Promise.all([
|
||||
record.update(rdoc.domainId, rdoc._id, { effective: true }),
|
||||
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),
|
||||
|
||||
@@ -257,7 +257,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
||||
const rdoc = await record.get(domainId, rid);
|
||||
if (!pretest) {
|
||||
await Promise.all([
|
||||
problem.inc(domainId, this.pdoc.docId, 'nSubmit', 1),
|
||||
this.psdoc?.rid ? Promise.resolve() : problem.inc(domainId, this.pdoc.docId, 'nSubmit', 1),
|
||||
problem.incStatus(domainId, this.pdoc.docId, this.user._id, 'nSubmit', 1),
|
||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
||||
]);
|
||||
|
||||
@@ -287,7 +287,6 @@ export interface RecordDoc {
|
||||
/** pretest */
|
||||
input?: string;
|
||||
contest?: ContestInfo;
|
||||
effective?: boolean;
|
||||
}
|
||||
|
||||
export interface ScoreboardNode {
|
||||
|
||||
@@ -21,8 +21,7 @@ class RecordModel {
|
||||
static PROJECTION_LIST: (keyof RecordDoc)[] = [
|
||||
'_id', 'score', 'time', 'memory', 'lang',
|
||||
'uid', 'pid', 'rejudged', 'hidden', 'progress',
|
||||
'contest', 'effective', 'judger', 'judgeAt', 'status',
|
||||
'pdomain',
|
||||
'contest', 'judger', 'judgeAt', 'status', 'pdomain',
|
||||
];
|
||||
|
||||
static async submissionPriority(uid: number, base: number = 0) {
|
||||
|
||||
@@ -21,7 +21,7 @@ export async function udoc(report) {
|
||||
{
|
||||
$group: {
|
||||
_id: { domainId: '$_id.domainId', uid: '$_id.uid' },
|
||||
nSubmit: { $sum: '$nSubmit' },
|
||||
nSubmit: { $sum: { $min: ['$nSubmit', 1] } },
|
||||
nAccept: { $sum: { $min: ['$nAccept', 1] } },
|
||||
},
|
||||
},
|
||||
@@ -68,7 +68,7 @@ export async function psdoc(report) {
|
||||
export async function pdoc(report) {
|
||||
report({ message: 'Pdoc' });
|
||||
const pipeline = [
|
||||
{ $match: { hidden: false, type: { $ne: 'run' }, effective: true } },
|
||||
{ $match: { hidden: false, type: { $ne: 'run' } } },
|
||||
{
|
||||
$group: {
|
||||
_id: { domainId: '$domainId', pid: '$pid', uid: '$uid' },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import { ObjectID } from 'mongodb';
|
||||
import AdmZip from 'adm-zip';
|
||||
import Queue from 'p-queue';
|
||||
import yaml from 'js-yaml';
|
||||
@@ -8,7 +8,6 @@ import { pick } from 'lodash';
|
||||
import { convertIniConfig } from '@hydrooj/utils/lib/cases';
|
||||
import { BucketItem } from 'minio';
|
||||
import { Progress } from './ui';
|
||||
import { RecordDoc } from './interface';
|
||||
import { Logger } from './logger';
|
||||
import { streamToBuffer } from './utils';
|
||||
import {
|
||||
@@ -24,7 +23,7 @@ import * as discussion from './model/discussion';
|
||||
import domain from './model/domain';
|
||||
import * as document from './model/document';
|
||||
import * as system from './model/system';
|
||||
import { PRIV, STATUS } from './model/builtin';
|
||||
import { PRIV } from './model/builtin';
|
||||
import RecordModel from './model/record';
|
||||
import StorageModel from './model/storage';
|
||||
import { size } from './lib/misc';
|
||||
@@ -242,37 +241,7 @@ const scripts: UpgradeScript[] = [
|
||||
});
|
||||
return true;
|
||||
},
|
||||
async function _19_20() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
const data = db.collection('record').aggregate([
|
||||
{ $match: { hidden: false, type: { $ne: 'run' } } },
|
||||
{
|
||||
$group: {
|
||||
_id: { domainId: '$domainId', pid: '$pid', uid: '$uid' },
|
||||
nAccept: {
|
||||
$sum: {
|
||||
$cond: [{ $eq: ['$status', STATUS.STATUS_ACCEPTED] }, 1, 0],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
while (await data.hasNext()) {
|
||||
const d: any = await data.next();
|
||||
logger.info('%o', d);
|
||||
const filter: FilterQuery<RecordDoc> = { domainId: d._id.domainId, pid: d._id.pid, uid: d._id.uid };
|
||||
if (d.nAccept) {
|
||||
const [first] = await db.collection('record')
|
||||
.find({ ...filter, status: STATUS.STATUS_ACCEPTED })
|
||||
.sort({ _id: 1 }).limit(1)
|
||||
.project({ _id: 1 })
|
||||
.toArray();
|
||||
filter._id = { $lte: first._id };
|
||||
}
|
||||
await db.collection('record').updateMany(filter, { $set: { effective: true } });
|
||||
}
|
||||
return true;
|
||||
},
|
||||
null,
|
||||
async function _20_21() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await iterateAllProblem([], async (pdoc) => {
|
||||
@@ -428,6 +397,11 @@ const scripts: UpgradeScript[] = [
|
||||
await iterateAllDomain((ddoc) => domain.edit(ddoc._id, { lower: ddoc._id.toLowerCase() }));
|
||||
return true;
|
||||
},
|
||||
async function _35_36() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await RecordModel.coll.updateMany({}, { $unset: { effective: '' } });
|
||||
return true;
|
||||
},
|
||||
];
|
||||
|
||||
export default scripts;
|
||||
Reference in new issue
Block a user