core: 计量尝试人数而非提交量

suggested by @Menci
This commit is contained in:
undefined committed 2021-06-28 19:57:07 +08:00
1 parent e5d715d02b
commit e49ffa9f7b
17 files changed
+102 -138

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.28.59",
"version": "2.29.0",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+3 -1
View File
@@ -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),
]);
+1 -1
View File
@@ -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),
-2
View File
@@ -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),
+1 -1
View File
@@ -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'),
]);
-1
View File
@@ -287,7 +287,6 @@ export interface RecordDoc {
/** pretest */
input?: string;
contest?: ContestInfo;
effective?: boolean;
}
export interface ScoreboardNode {
+1 -2
View File
@@ -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) {
+2 -2
View File
@@ -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' },
+8 -34
View File
@@ -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;
+1
View File
@@ -754,6 +754,7 @@ training_create: 创建训练
training_edit: 编辑训练
training_main: 训练
Training: 训练
Tried: 尝试
Type: 类型
UI Language: 用户界面语言
Uncompleted: 未完成
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.11.45",
"version": "4.11.46",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -10,23 +10,23 @@
width: rem(140px)
position: relative
.col--submit_n, .col--ac_rate, .col--difficulty
.col--tried, .col--ac, .col--difficulty
width: rem(70px)
text-align: center
.col--status
border-right: 1px solid $table-border-color
.col--submit_n, .col--difficulty
.col--tried, .col--difficulty
border-left: 1px solid $table-border-color
+mobile()
.col--status,
.col--submit_n,
.col--tried,
.col--difficulty
display: none
.col--ac_rate
.col--ac
border-left: 1px solid $table-border-color
@@ -3,23 +3,23 @@
width: rem(150px)
position: relative
.col--submit_n, .col--ac_rate, .col--difficulty
.col--tried, .col--ac, .col--difficulty
width: rem(70px)
text-align: center
.col--status
border-right: 1px solid $table-border-color
.col--submit_n, .col--difficulty
.col--tried, .col--difficulty
border-left: 1px solid $table-border-color
+mobile()
.col--status,
.col--submit_n,
.col--tried,
.col--difficulty
display: none
.col--ac_rate
.col--ac
border-left: 1px solid $table-border-color
.training__section
@@ -35,16 +35,8 @@
</dd>
<dt>{{ _('# Submissions') }}</dt>
<dd><a href="{{ url('record_main', query={pid:pdoc.docId}) }}">{{ pdoc.nSubmit }}</a></dd>
{% if page_name != 'discussion_node' and page_name != 'discussion_detail' %}
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<dt>{{ _('# My Submissions') }}</dt>
<dd><a href="{{ url('record_main', query={pid:pdoc.docId, uidOrName:handler.user._id}) }}">{{ pdoc['psdoc'].nSubmit|default(0) }}</a></dd>
{% endif %}
{% endif %}
<dt>{{ _('Accepted') }}</dt>
<dd>{{ pdoc.nAccept }}</dd>
<dt>{{ _('Accepted Ratio') }}</dt>
<dd>{% if pdoc.nSubmit > 0 %}{{ (100 * pdoc.nAccept / pdoc.nSubmit)|round|int }}%{% else %}{{ _('?') }}{% endif %}</dd>
<dt>{{ _('Uploaded By') }}</dt>
<dd>{{ user.render_inline(owner_udoc, badge=false) }}</dd>
</dl>
@@ -61,8 +61,8 @@
<td class="col--name col--problem-name">
{{ problem.render_problem_title(pdoc) }}
</td>
<td class="col--submit_n">{{ pdoc['nSubmit'] }}</td>
<td class="col--ac_rate">{{ (100 * pdoc['nAccept'] / pdoc['nSubmit'])|round|int if pdoc['nSubmit'] > 0 else _('?') }}</td>
<td class="col--tried">{{ pdoc.nSubmit }}</td>
<td class="col--ac">{{ pdoc.nAccept }}</td>
<td class="col--difficulty">{{ pdoc['difficulty'] or _('(None)') }}</td>
</tr>
{%- endfor -%}
@@ -44,9 +44,8 @@
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Time') }}: {{ pdoc.config.timeMax if pdoc.config.timeMax == pdoc.config.timeMin else pdoc.config.timeMin+'~'+pdoc.config.timeMax }}ms</span>
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Memory') }}: {{ pdoc.config.memoryMax if pdoc.config.memoryMax == pdoc.config.memoryMin else pdoc.config.memoryMin+'~'+pdoc.config.memoryMax }}MiB</span>
{% endif %}
<a class="bp3-tag bp3-large bp3-minimal bp3-interactive problem__tag-item" href="{{ url('record_main', query={pid:pdoc.docId}) }}">{{ _('Submitted') }}: {{ pdoc.nSubmit }}</a>
<a class="bp3-tag bp3-large bp3-minimal bp3-interactive problem__tag-item" href="{{ url('record_main', query={pid:pdoc.docId}) }}">{{ _('Tried') }}: {{ pdoc.nSubmit }}</a>
<a class="bp3-tag bp3-large bp3-minimal bp3-interactive problem__tag-item" href="{{ url('record_main', query={pid:pdoc.docId, status:1}) }}">{{ _('Accepted') }}: {{ pdoc.nAccept }}</a>
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Accepted Ratio') }}: {% if pdoc.nSubmit > 0 %}{{ (100 * pdoc.nAccept / pdoc.nSubmit)|round|int }}%{% else %}{{ _('?') }}{% endif %}</span>
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Difficulty') }}: {{ pdoc['difficulty'] or _('(None)') }}</span>
<span class="bp3-tag bp3-large bp3-minimal bp3-interactive problem__tag-item">{{ _('Uploaded By') }}: {{ user.render_inline(udoc, badge=false) }}</span>
{% if pdoc.tag.length %}
@@ -76,82 +76,82 @@
{{ node['content']|markdown|safe }}
</div>
{% endif %}
<div class="section__body no-padding training__problems">
<table class="data-table">
<colgroup>
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<col class="col--status">
{% endif %}
<col class="col--name">
<col class="col--submit_n">
<col class="col--ac_rate">
<col class="col--difficulty">
</colgroup>
<thead>
<tr>
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<th class="col--status record-status--border">{{ _('Status') }}</th>
{% endif %}
<th class="col--name">{{ _('Problem') }}</th>
<th class="col--submit_n">{{ _('Submit') }}</th>
<th class="col--ac_rate">% {{ _('AC') }}</th>
<th class="col--difficulty">{{ _('Difficulty') }}</th>
</tr>
</thead>
<tbody>
{%- for pid in node['pids'] -%}
{% if pid in pdict %}
{% set pdoc=pdict[pid] %}
{% set psdoc=psdict[pid] %}
<tr>
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
{% if psdoc['rid'] %}
{{ record.render_status_td(psdoc, rid_key='rid') }}
{% else %}
<td class="col--status record-status--border"></td>
{% endif %}
{% endif %}
<td class="col--name col--problem-name">
<div class="section__body no-padding training__problems">
<table class="data-table">
<colgroup>
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<form class="form--inline" action="{{ url('problem_main') }}" method="post">
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
<input type="hidden" name="operation" value="{% if not psdoc['star'] %}star{% else %}unstar{% endif %}">
<input type="hidden" name="csrfToken" value="{{ handler.csrfToken }}">
<button class="star{% if psdoc['star'] %} activated{% endif %}" type="submit">
<span class="starred--hide"><span class="icon icon-star--outline" data-tooltip="{{ _('Star') }}"></span></span>
<span class="starred--show"><span class="icon icon-star" data-tooltip="{{ _('Unstar') }}"></span></span>
</button>
</form>
<col class="col--status">
{% endif %}
{{ problem.render_problem_title(
pdoc,
invalid=not tsdoc['enroll'],
show_tags=false
) }}
</td>
<td class="col--submit_n">{{ pdoc.nSubmit }}</td>
<td class="col--ac_rate">{{ (100 * pdoc.nAccept / pdoc.nSubmit)|round|int if pdoc.nSubmit > 0 else _('?') }}</td>
<td class="col--difficulty">{{ pdoc['difficulty'] or _('(None)') }}</td>
</tr>
{% else %}
{% set pdoc = {'_id': pid, 'hidden': true, 'title': '*'} %}
<tr>
<td class="col--status record-status--border">
</td>
<td class="col--name col--problem-name">
{{ problem.render_problem_title(pdoc, invalid=true) }}
</td>
<td class="col--submit_n">*</td>
<td class="col--ac_rate">*</td>
<td class="col--difficulty">*</td>
</tr>
{% endif %}
{%- endfor -%}
</tbody>
</table>
<col class="col--name">
<col class="col--submit_n">
<col class="col--ac_rate">
<col class="col--difficulty">
</colgroup>
<thead>
<tr>
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<th class="col--status record-status--border">{{ _('Status') }}</th>
{% endif %}
<th class="col--name">{{ _('Problem') }}</th>
<th class="col--submit_n">{{ _('Tried') }}</th>
<th class="col--ac_rate">% {{ _('AC') }}</th>
<th class="col--difficulty">{{ _('Difficulty') }}</th>
</tr>
</thead>
<tbody>
{%- for pid in node['pids'] -%}
{% if pid in pdict %}
{% set pdoc=pdict[pid] %}
{% set psdoc=psdict[pid] %}
<tr>
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
{% if psdoc['rid'] %}
{{ record.render_status_td(psdoc, rid_key='rid') }}
{% else %}
<td class="col--status record-status--border"></td>
{% endif %}
{% endif %}
<td class="col--name col--problem-name">
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<form class="form--inline" action="{{ url('problem_main') }}" method="post">
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
<input type="hidden" name="operation" value="{% if not psdoc['star'] %}star{% else %}unstar{% endif %}">
<input type="hidden" name="csrfToken" value="{{ handler.csrfToken }}">
<button class="star{% if psdoc['star'] %} activated{% endif %}" type="submit">
<span class="starred--hide"><span class="icon icon-star--outline" data-tooltip="{{ _('Star') }}"></span></span>
<span class="starred--show"><span class="icon icon-star" data-tooltip="{{ _('Unstar') }}"></span></span>
</button>
</form>
{% endif %}
{{ problem.render_problem_title(
pdoc,
invalid=not tsdoc['enroll'],
show_tags=false
) }}
</td>
<td class="col--tried">{{ pdoc.nSubmit }}</td>
<td class="col--ac">{{ pdoc.nAccept }}</td>
<td class="col--difficulty">{{ pdoc['difficulty'] or _('(None)') }}</td>
</tr>
{% else %}
{% set pdoc = {'_id': pid, 'hidden': true, 'title': '*'} %}
<tr>
<td class="col--status record-status--border">
</td>
<td class="col--name col--problem-name">
{{ problem.render_problem_title(pdoc, invalid=true) }}
</td>
<td class="col--submit_n">*</td>
<td class="col--ac_rate">*</td>
<td class="col--difficulty">*</td>
</tr>
{% endif %}
{%- endfor -%}
</tbody>
</table>
</div>
</div>
</div>
</div>
{%- endfor -%}
<div class="section__body">&nbsp;<!-- space placeholder --></div>
</div>