mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: add score range display
This commit is contained in:
1 parent
3f5d456d32
commit
ec83da1080
6 files changed
+48
-25
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.26.5",
|
"version": "2.26.6",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ async function _postJudge(rdoc: RecordDoc) {
|
|||||||
record.update(rdoc.domainId, rdoc._id, { effective: true }),
|
record.update(rdoc.domainId, rdoc._id, { effective: true }),
|
||||||
problem.edit(pdoc.domainId, pdoc.docId, { difficulty }),
|
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.${builtin.STATUS_SHORT_TEXTS[rdoc.status]}`, 1),
|
||||||
|
problem.inc(pdoc.domainId, pdoc.docId, `stats.s${rdoc.score}`, 1),
|
||||||
]);
|
]);
|
||||||
await bus.serial('record/judge', rdoc, updated);
|
await bus.serial('record/judge', rdoc, updated);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export async function udoc(report) {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
let bulk = db.collection('domain.user').initializeUnorderedBulkOp();
|
let bulk = db.collection('domain.user').initializeUnorderedBulkOp();
|
||||||
const cursor = db.collection('record').aggregate(pipeline);
|
const cursor = db.collection('record').aggregate(pipeline, { allowDiskUse: true });
|
||||||
while (await cursor.hasNext()) {
|
while (await cursor.hasNext()) {
|
||||||
const adoc = await cursor.next() as any;
|
const adoc = await cursor.next() as any;
|
||||||
bulk.find({
|
bulk.find({
|
||||||
@@ -58,7 +58,7 @@ export async function psdoc(report) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const data = db.collection('record').aggregate(pipeline);
|
const data = db.collection('record').aggregate(pipeline, { allowDiskUse: true });
|
||||||
while (await data.hasNext()) {
|
while (await data.hasNext()) {
|
||||||
const adoc = await data.next() as any;
|
const adoc = await data.next() as any;
|
||||||
await document.setStatus(adoc._id.domainId, document.TYPE_PROBLEM, adoc._id.pid, adoc._id.uid, { nSubmit: adoc.nSubmit });
|
await document.setStatus(adoc._id.domainId, document.TYPE_PROBLEM, adoc._id.pid, adoc._id.uid, { nSubmit: adoc.nSubmit });
|
||||||
@@ -99,17 +99,16 @@ export async function pdoc(report) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
for (let i = 0; i <= 100; i++) {
|
||||||
|
pipeline[1].$group[`s${i}`] = { $sum: { $cond: [{ $eq: ['$score', i] }, 1, 0] } };
|
||||||
|
pipeline[2].$group[`s${i}`] = { $sum: `$s${i}` };
|
||||||
|
}
|
||||||
let bulk = db.collection('document').initializeUnorderedBulkOp();
|
let bulk = db.collection('document').initializeUnorderedBulkOp();
|
||||||
const data = db.collection('record').aggregate(pipeline);
|
const data = db.collection('record').aggregate(pipeline, { allowDiskUse: true });
|
||||||
let cnt = 0;
|
let cnt = 0;
|
||||||
while (await data.hasNext()) {
|
while (await data.hasNext()) {
|
||||||
const adoc = await data.next() as any;
|
const adoc = await data.next() as any;
|
||||||
bulk.find({
|
const $set = {
|
||||||
domainId: adoc._id.domainId,
|
|
||||||
docType: document.TYPE_PROBLEM,
|
|
||||||
docId: adoc._id.pid,
|
|
||||||
}).updateOne({
|
|
||||||
$set: {
|
|
||||||
nSubmit: adoc.nSubmit,
|
nSubmit: adoc.nSubmit,
|
||||||
nAccept: adoc.nAccept,
|
nAccept: adoc.nAccept,
|
||||||
'stats.AC': adoc.AC,
|
'stats.AC': adoc.AC,
|
||||||
@@ -120,8 +119,13 @@ export async function pdoc(report) {
|
|||||||
'stats.SE': adoc.SE,
|
'stats.SE': adoc.SE,
|
||||||
'stats.IGN': adoc.IGN,
|
'stats.IGN': adoc.IGN,
|
||||||
'stats.CE': adoc.CE,
|
'stats.CE': adoc.CE,
|
||||||
},
|
};
|
||||||
});
|
for (let i = 0; i <= 100; i++) if (adoc[`s${i}`]) $set[`stats.s${i}`] = adoc[`s${i}`];
|
||||||
|
bulk.find({
|
||||||
|
domainId: adoc._id.domainId,
|
||||||
|
docType: document.TYPE_PROBLEM,
|
||||||
|
docId: adoc._id.pid,
|
||||||
|
}).updateOne({ $set });
|
||||||
if (bulk.length > 100) {
|
if (bulk.length > 100) {
|
||||||
await bulk.execute();
|
await bulk.execute();
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.8.19",
|
"version": "4.8.20",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import delay from 'vj/utils/delay';
|
|||||||
import i18n from 'vj/utils/i18n';
|
import i18n from 'vj/utils/i18n';
|
||||||
import request from 'vj/utils/request';
|
import request from 'vj/utils/request';
|
||||||
import base64 from 'vj/utils/base64';
|
import base64 from 'vj/utils/base64';
|
||||||
|
import { getScoreColor } from 'vj/../utils/lib/status';
|
||||||
|
|
||||||
class ProblemPageExtender {
|
class ProblemPageExtender {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -251,9 +252,10 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
|
|||||||
|
|
||||||
if (pagename === 'contest_detail_problem') return;
|
if (pagename === 'contest_detail_problem') return;
|
||||||
const data = await request.get('');
|
const data = await request.get('');
|
||||||
const $dom = document.getElementById('submission-detail-placeholder');
|
data.pdoc.stats = data.pdoc.stats || {};
|
||||||
const chart = echarts.init($dom);
|
const $status = document.getElementById('submission-status-placeholder');
|
||||||
chart.setOption({
|
const statusChart = echarts.init($status);
|
||||||
|
statusChart.setOption({
|
||||||
tooltip: { trigger: 'item' },
|
tooltip: { trigger: 'item' },
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
@@ -262,18 +264,33 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
|
|||||||
radius: [10, 70],
|
radius: [10, 70],
|
||||||
roseType: 'radius',
|
roseType: 'radius',
|
||||||
data: [
|
data: [
|
||||||
{ value: data.pdoc.stats?.TLE, name: 'TLE' },
|
{ value: data.pdoc.stats.TLE, name: 'TLE' },
|
||||||
{ value: data.pdoc.stats?.AC, name: 'AC' },
|
{ value: data.pdoc.stats.AC, name: 'AC' },
|
||||||
{ value: data.pdoc.stats?.MLE, name: 'MLE' },
|
{ value: data.pdoc.stats.MLE, name: 'MLE' },
|
||||||
{ value: data.pdoc.stats?.WA, name: 'WA' },
|
{ value: data.pdoc.stats.WA, name: 'WA' },
|
||||||
{ value: data.pdoc.stats?.RE, name: 'RE' },
|
{ value: data.pdoc.stats.RE, name: 'RE' },
|
||||||
{ value: data.pdoc.stats?.CE, name: 'CE' },
|
{ value: data.pdoc.stats.CE, name: 'CE' },
|
||||||
{ value: data.pdoc.stats?.SE, name: 'SE' },
|
{ value: data.pdoc.stats.SE, name: 'SE' },
|
||||||
{ value: data.pdoc.stats?.IGN, name: 'IGN' },
|
{ value: data.pdoc.stats.IGN, name: 'IGN' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
const $score = document.getElementById('submission-score-placeholder');
|
||||||
|
const x = Array.from({ length: 101 }, (v, i) => i).filter((i) => data.pdoc.stats[`s${i}`]);
|
||||||
|
const scoreChart = echarts.init($score);
|
||||||
|
scoreChart.setOption({
|
||||||
|
tooltip: { trigger: 'item' },
|
||||||
|
xAxis: { data: x },
|
||||||
|
yAxis: {},
|
||||||
|
series: [{
|
||||||
|
data: x.map((i) => ({
|
||||||
|
value: data.pdoc.stats[`s${i}`],
|
||||||
|
itemStyle: { color: getScoreColor(i) },
|
||||||
|
})),
|
||||||
|
type: 'bar',
|
||||||
|
}],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export default page;
|
export default page;
|
||||||
@@ -117,7 +117,8 @@
|
|||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('Statistics') }}</h1>
|
<h1 class="section__title">{{ _('Statistics') }}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div id="submission-detail-placeholder" style="width: 100%; height:230px"></div>
|
<div id="submission-status-placeholder" style="width: 100%; height:230px"></div>
|
||||||
|
<div id="submission-score-placeholder" style="width: 100%; height:230px"></div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if page_name == 'problem_detail' and (tdocs or ctdocs) %}
|
{% if page_name == 'problem_detail' and (tdocs or ctdocs) %}
|
||||||
|
|||||||
Reference in new issue
Block a user