core: fix contest discussion index

This commit is contained in:
undefined committed 2021-09-20 18:54:56 +08:00
1 parent 90283a3944
commit 895b91d8ab
4 files changed
+33 -18

No files matched your search

+15 -16
View File
@@ -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);';
}
+1 -1
View File
@@ -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),
+16
View File
@@ -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;