Merge branch 'master' into remove-union

This commit is contained in:
undefined committed 2024-10-18 06:16:19 +08:00
commit baeafe7cd3
17 files changed
+107 -74

No files matched your search

+1 -3
View File
@@ -121,14 +121,12 @@ export class HomeHandler extends Handler {
if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)) return [[], {}];
const psdocs = await ProblemModel.getMultiStatus(domainId, { uid: this.user._id, star: true })
.sort('_id', 1).limit(limit).toArray();
const psdict = {};
for (const psdoc of psdocs) psdict[psdoc.docId] = psdoc;
const pdict = await ProblemModel.getList(
domainId, psdocs.map((pdoc) => pdoc.docId),
this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || this.user._id, false,
);
const pdocs = Object.keys(pdict).filter((i) => +i).map((i) => pdict[i]);
return [pdocs, psdict];
return [pdocs];
}
async getRecentProblems(domainId: string, limit = 10) {
+6 -12
View File
@@ -186,18 +186,6 @@ export class ProblemMainHandler extends Handler {
}
}
@param('pid', Types.UnsignedInt)
async postStar(domainId: string, pid: number) {
await problem.setStar(domainId, pid, this.user._id, true);
this.back({ star: true });
}
@param('pid', Types.UnsignedInt)
async postUnstar(domainId: string, pid: number) {
await problem.setStar(domainId, pid, this.user._id, false);
this.back({ star: false });
}
@param('pids', Types.NumericArray)
@param('target', Types.String)
async postCopy(domainId: string, pids: number[], target: string) {
@@ -438,6 +426,12 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
await problem.del(this.pdoc.domainId, this.pdoc.docId);
this.response.redirect = this.url('problem_main');
}
@param('star', Types.Boolean)
async postStar(domainId: string, star: boolean) {
await problem.setStar(domainId, this.pdoc.docId, this.user._id, star);
this.back({ star });
}
}
export class ProblemSubmitHandler extends ProblemDetailHandler {