core: fix contest discussion index

pull/220/head
undefined 3 years ago
parent 90283a3944
commit 895b91d8ab

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.36.10",
"version": "2.36.11",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",

@ -241,24 +241,23 @@ const oi: ContestRule = {
const index = pid.toString().includes(':')
? `${tsdoc.uid}/${pid.toString().replace(':', '/')}`
: `${tsdoc.uid}/${tdoc.domainId}/${pid}`;
const node: ScoreboardNode =
// eslint-disable-next-line @typescript-eslint/no-use-before-define
isDone(tdoc) && tsddict[pid]?.rid?.toHexString() !== psdict[index]?.rid?.toHexString()
? {
type: 'records',
value: '',
raw: [{
value: tsddict[pid]?.score ?? '-',
raw: tsddict[pid]?.rid || null,
}, {
value: psdict[index]?.score ?? '-',
raw: psdict[index]?.rid ?? null,
}],
} : {
type: 'record',
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const node: ScoreboardNode = isDone(tdoc) && tsddict[pid]?.rid?.toHexString() !== psdict[index]?.rid?.toHexString()
? {
type: 'records',
value: '',
raw: [{
value: tsddict[pid]?.score ?? '-',
raw: tsddict[pid]?.rid || null,
};
}, {
value: psdict[index]?.score ?? '-',
raw: psdict[index]?.rid ?? null,
}],
} : {
type: 'record',
value: tsddict[pid]?.score ?? '-',
raw: tsddict[pid]?.rid || null,
};
if (tsddict[pid]?.status === STATUS.STATUS_ACCEPTED && tsddict[pid]?.rid.generationTime === first[pid]) {
node.style = 'background-color: rgb(217, 240, 199);';
}

@ -258,7 +258,7 @@ export async function getVnode(domainId: string, type: number, id: string, uid?:
const tsdoc = await model.getStatus(domainId, _id, uid);
tdoc.attend = tsdoc?.attend || tsdoc?.enroll;
}
return { ...tdoc, type, id };
return { ...tdoc, type, id: _id };
}
return {
...await getNode(domainId, id),

@ -519,6 +519,22 @@ const scripts: UpgradeScript[] = [
await iterateAllUser((udoc) => user.setById(udoc._id, { ip: [udoc.regip] }, { regip: '' }));
return true;
},
async function _45_46() {
const _FRESH_INSTALL_IGNORE = 1;
await iterateAllDomain(async (ddoc) => {
const ddocs = await discussion.getMulti(ddoc._id, {
docType: document.TYPE_DISCUSSION,
parentType: { $in: [document.TYPE_CONTEST, document.TYPE_HOMEWORK, document.TYPE_TRAINING] },
parentId: { $type: 'string' },
}).toArray();
for (const doc of ddocs) {
if (ObjectID.isValid(doc.parentId)) {
await document.set(ddoc._id, document.TYPE_DISCUSSION, doc.docId, { parentId: new ObjectID(doc.parentId) });
}
}
});
return true;
},
];
export default scripts;

Loading…
Cancel
Save