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
+19 -4

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.36.10",
"version": "2.36.11",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+1 -2
View File
@@ -241,9 +241,8 @@ 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()
const node: ScoreboardNode = isDone(tdoc) && tsddict[pid]?.rid?.toHexString() !== psdict[index]?.rid?.toHexString()
? {
type: 'records',
value: '',
+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;