This commit is contained in:
undefined committed 2023-04-08 02:32:10 +08:00
1 parent 9f1169b3e0
commit 205475b859
3 files changed
+23 -7

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "4.9.10", "version": "4.9.11",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/plugin-api", "main": "src/plugin-api",
"module": "src/plugin-api", "module": "src/plugin-api",
+12 -4
View File
@@ -15,6 +15,8 @@ import { ScoreboardConfig, Tdoc } from '../interface';
import paginate from '../lib/paginate'; import paginate from '../lib/paginate';
import { PERM, PRIV, STATUS } from '../model/builtin'; import { PERM, PRIV, STATUS } from '../model/builtin';
import * as contest from '../model/contest'; import * as contest from '../model/contest';
import * as discussion from '../model/discussion';
import document from '../model/document';
import message from '../model/message'; import message from '../model/message';
import * as oplog from '../model/oplog'; import * as oplog from '../model/oplog';
import problem from '../model/problem'; import problem from '../model/problem';
@@ -460,11 +462,17 @@ export class ContestEditHandler extends Handler {
@param('tid', Types.ObjectId) @param('tid', Types.ObjectId)
async postDelete(domainId: string, tid: ObjectId) { async postDelete(domainId: string, tid: ObjectId) {
if (!this.user.own(this.tdoc)) this.checkPerm(PERM.PERM_EDIT_CONTEST); if (!this.user.own(this.tdoc)) this.checkPerm(PERM.PERM_EDIT_CONTEST);
await contest.del(domainId, tid); const [ddocs] = await Promise.all([
await record.updateMulti(domainId, { domainId, contest: tid }, undefined, undefined, { contest: '' }); discussion.getMulti(domainId, { parentType: document.TYPE_CONTEST, parentId: tid }).project({ _id: 1 }).toArray(),
await ScheduleModel.deleteMany({ contest.del(domainId, tid),
]);
const tasks: any[] = ddocs.map((i) => discussion.del(domainId, i._id));
await Promise.all(tasks.concat([
record.updateMulti(domainId, { domainId, contest: tid }, undefined, undefined, { contest: '' }),
ScheduleModel.deleteMany({
type: 'schedule', subType: 'contest', domainId, tid, type: 'schedule', subType: 'contest', domainId, tid,
}); }),
]));
this.response.redirect = this.url('contest_main'); this.response.redirect = this.url('contest_main');
} }
} }
+10 -2
View File
@@ -563,13 +563,21 @@ const scripts: UpgradeScript[] = [
r.journal = r.journal.filter((i) => i.rid !== null); r.journal = r.journal.filter((i) => i.rid !== null);
await document.collStatus.updateOne({ _id: r._id }, { $set: { journal: r.journal } }); await document.collStatus.updateOne({ _id: r._id }, { $set: { journal: r.journal } });
} }
await iterateAllContest(async (tdoc) => { return await iterateAllContest(async (tdoc) => {
if (tdoc.rule !== 'acm') return; if (tdoc.rule !== 'acm') return;
logger.info(tdoc.domainId, tdoc.title); logger.info(tdoc.domainId, tdoc.title);
await contest.recalcStatus(tdoc.domainId, tdoc.docId); await contest.recalcStatus(tdoc.domainId, tdoc.docId);
if (contest.isDone(tdoc)) await contest.unlockScoreboard(tdoc.domainId, tdoc.docId); if (contest.isDone(tdoc)) await contest.unlockScoreboard(tdoc.domainId, tdoc.docId);
}); });
return true; },
async function _79_80() {
return await iterateAllDomain(async ({ _id }) => {
const cursor = discussion.getMulti(_id, { parentType: document.TYPE_CONTEST });
for await (const ddoc of cursor) {
const tdoc = await contest.get(_id, ddoc.parentId as ObjectId);
if (!tdoc) await discussion.del(_id, ddoc.docId);
}
});
}, },
]; ];