core: fix contest discussion parentId (#662)

This commit is contained in:
panda authored and GitHub committed 2023-09-20 21:42:22 +08:00
1 parent 385d90fa39
commit a9b2f68d2d
2 files changed
+15 -1

No files matched your search

+1 -1
View File
@@ -288,7 +288,7 @@ export async function getVnode(domainId: string, type: number, id: string, uid?:
tdoc.attend = tsdoc?.attend || tsdoc?.enroll;
}
return {
...tdoc, type, id, hidden: false,
...tdoc, type, id: _id, hidden: false,
};
}
return {
+14
View File
@@ -616,6 +616,20 @@ const scripts: UpgradeScript[] = [
}
return true;
},
async function _84_85() {
return await iterateAllDomain(async ({ _id }) => {
const cursor = discussion.getMulti(_id, { parentType: document.TYPE_CONTEST });
for await (const ddoc of cursor) {
const parentId = new ObjectId(ddoc.parentId);
await discussion.edit(_id, ddoc.docId, { parentId });
try {
await contest.get(_id, parentId);
} catch (e) {
await discussion.del(_id, ddoc.docId);
}
}
});
},
];
export default scripts;