Skip to content

Commit

Permalink
core: fix contest vnode id is not a ObjectId
Browse files Browse the repository at this point in the history
  • Loading branch information
pandadtdyy committed Sep 19, 2023
1 parent 84962bf commit 1bdd032
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/hydrooj/src/model/discussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions packages/hydrooj/src/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,18 @@ 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) {
try {
await contest.get(_id, ddoc.parentId as ObjectId);
} catch (e) {
await discussion.del(_id, ddoc.docId);
}
}
});
},
];

export default scripts;

0 comments on commit 1bdd032

Please sign in to comment.