core: fix stats handle for non-integer score

This commit is contained in:
undefined committed 2022-09-14 21:56:03 +08:00
1 parent 7b112817c6
commit a648d51969
4 files changed
+13 -4

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.17.6",
"version": "3.17.7",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+1 -1
View File
@@ -78,7 +78,7 @@ export async function postJudge(rdoc: RecordDoc) {
if (isNormalSubmission) {
await Promise.all([
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),
problem.inc(pdoc.domainId, pdoc.docId, `stats.s${Math.floor(rdoc.score)}`, 1),
]);
}
if (rdoc.status === STATUS.STATUS_HACK_SUCCESSFUL) {
+10 -1
View File
@@ -105,7 +105,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[1].$group[`s${i}`] = {
$sum: {
$cond: [{
$and: [
{ $gte: ['$score', i] },
{ $lt: ['$score', i + 1] },
],
}, 1, 0],
},
};
pipeline[2].$group[`s${i}`] = { $sum: `$s${i}` };
}
let bulk = db.collection('document').initializeUnorderedBulkOp();
+1 -1
View File
@@ -830,7 +830,7 @@ const scripts: UpgradeScript[] = [
}
return true;
},
async function _67_78() {
async function _67_68() {
const _FRESH_INSTALL_IGNORE = 1;
const rdocs = RecordModel.coll.find({ code: /^@@hydro_submission_file@@/ });
let rdoc;