Skip to content

Commit

Permalink
core: fix contest discussion parentId (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
pandadtdyy authored Sep 20, 2023
1 parent 385d90f commit a9b2f68
Show file tree
Hide file tree
Showing 2 changed files with 15 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
14 changes: 14 additions & 0 deletions packages/hydrooj/src/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

1 comment on commit a9b2f68

@nooooocato
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

谢谢!

Please sign in to comment.