core: fix acm scoreboard

This commit is contained in:
undefined committed 2021-08-30 22:32:28 +08:00
1 parent ee2ba9c712
commit a33d8e768f
3 files changed
+33 -10

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.33.13", "version": "2.33.14s",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
+10 -9
View File
@@ -46,7 +46,7 @@ const acm: ContestRule = {
let time = 0; let time = 0;
for (const j of journal) { for (const j of journal) {
if (tdoc.pids.includes(j.pid) if (tdoc.pids.includes(j.pid)
&& !(effective[j.pid] && effective[j.pid].accept)) { && !(effective[j.pid]?.status === STATUS.STATUS_ACCEPTED)) {
effective[j.pid] = j; effective[j.pid] = j;
if (![STATUS.STATUS_ACCEPTED, STATUS.STATUS_COMPILE_ERROR].includes(j.status)) { if (![STATUS.STATUS_ACCEPTED, STATUS.STATUS_COMPILE_ERROR].includes(j.status)) {
naccept[j.pid] = (naccept[j.pid] || 0) + 1; naccept[j.pid] = (naccept[j.pid] || 0) + 1;
@@ -127,10 +127,11 @@ const acm: ContestRule = {
} }
for (const pid of tdoc.pids) { for (const pid of tdoc.pids) {
const doc = tsddict[pid] || {}; const doc = tsddict[pid] || {};
const rid = doc.accept ? doc.rid : null; const accept = doc.status === STATUS.STATUS_ACCEPTED;
const colAccepted = `${doc.accept ? `${_('Accepted')} ` : ''}${doc.naccept ? ` (-${doc.naccept})` : ''}`; const rid = accept ? doc.rid : null;
const colTime = doc.accept ? doc.time : '-'; const colAccepted = `${accept ? `${_('Accepted')} ` : ''}${doc.naccept ? ` (-${doc.naccept})` : ''}`;
const colTimeStr = doc.accept ? misc.formatSeconds(colTime) : '-'; const colTime = accept ? doc.time : '-';
const colTimeStr = accept ? misc.formatSeconds(colTime) : '-';
if (isExport) { if (isExport) {
row.push({ type: 'string', value: colAccepted }); row.push({ type: 'string', value: colAccepted });
row.push({ type: 'string', value: colTime }); row.push({ type: 'string', value: colTime });
@@ -138,7 +139,7 @@ const acm: ContestRule = {
} else { } else {
row.push({ row.push({
type: 'record', type: 'record',
score: doc.accept ? 100 : 0, score: accept ? 100 : 0,
value: '{0}\n{1}'.format(colAccepted, colTimeStr), value: '{0}\n{1}'.format(colAccepted, colTimeStr),
raw: rid, raw: rid,
}); });
@@ -200,7 +201,7 @@ const oi: ContestRule = {
const tsddict = {}; const tsddict = {};
for (const item of tsdoc.journal || []) tsddict[item.pid] = item; for (const item of tsdoc.journal || []) tsddict[item.pid] = item;
for (const pid of tdoc.pids) { for (const pid of tdoc.pids) {
if (tsddict[pid]?.accept && tsddict[pid].rid.generationTime < first[pid]) { if (tsddict[pid]?.status === STATUS.STATUS_ACCEPTED && tsddict[pid].rid.generationTime < first[pid]) {
first[pid] = tsddict[pid].rid.generationTime; first[pid] = tsddict[pid].rid.generationTime;
} }
} }
@@ -261,7 +262,7 @@ const oi: ContestRule = {
value: tsddict[pid]?.score ?? '-', value: tsddict[pid]?.score ?? '-',
raw: tsddict[pid]?.rid || null, raw: tsddict[pid]?.rid || null,
}; };
if (tsddict[pid]?.accept && tsddict[pid]?.rid.generationTime === first[pid]) { if (tsddict[pid]?.status === STATUS.STATUS_ACCEPTED && tsddict[pid]?.rid.generationTime === first[pid]) {
node.style = 'background-color: rgb(217, 240, 199);'; node.style = 'background-color: rgb(217, 240, 199);';
} }
row.push(node); row.push(node);
@@ -291,7 +292,7 @@ const homework: ContestRule = {
stat: (tdoc, journal) => { stat: (tdoc, journal) => {
const effective = {}; const effective = {};
for (const j of journal) { for (const j of journal) {
if (tdoc.pids.includes(j.pid) && (!effective[j.pid] || j.accept)) { if (tdoc.pids.includes(j.pid) && (!effective[j.pid] || j.status === STATUS.STATUS_ACCEPTED)) {
effective[j.pid] = j; effective[j.pid] = j;
} }
} }
+22
View File
@@ -493,6 +493,28 @@ const scripts: UpgradeScript[] = [
}); });
return true; return true;
}, },
async function _43_44() {
const _FRESH_INSTALL_IGNORE = 1;
const processer = (i) => {
i.status = i.accept ? STATUS.STATUS_ACCEPTED : STATUS.STATUS_WRONG_ANSWER;
return i;
};
await iterateAllDomain(async (ddoc) => {
const tdocs = await contest.getMulti(ddoc._id, { rule: { $ne: 'acm' } }).toArray();
for (const tdoc of tdocs) {
const tsdocs = await contest.getMultiStatus(ddoc._id, { docId: tdoc.docId }).toArray();
for (const tsdoc of tsdocs) {
const $set: any = {};
if (tsdoc.journal?.length) $set.journal = tsdoc.journal.map(processer);
if (tsdoc.detail?.length) $set.detail = tsdoc.detail.map(processer);
if (Object.keys($set).length) {
await contest.setStatus(ddoc._id, tdoc.docId, tsdoc.uid, $set);
}
}
}
});
return true;
},
]; ];
export default scripts; export default scripts;