core: add controlled rejudge (#969)

Co-authored-by: panda <panda_dtdyy@outlook.com>
This commit is contained in:
undefinedandpanda authored and GitHub committed 2025-04-01 11:34:06 +01:00
1 parent 536c697f4b
commit 466bc984bd
12 files changed
+170 -119

No files matched your search

+11 -9
View File
@@ -248,18 +248,20 @@ export default class RecordModel {
};
if (isRejudge) upd.rejudged = true;
const [rdocs] = await Promise.all([
RecordModel.coll.find({ _id: { $in: rids } }).toArray(),
RecordModel.coll.find({ _id: { $in: rids }, judgeAt: { $exists: true, $ne: null } }).toArray(),
RecordModel.collStat.deleteMany({ _id: { $in: rids } }),
task.deleteMany({ rid: { $in: rids } }),
]);
await RecordModel.collHistory.insertMany(rdocs.filter((rdoc) => rdoc.judgeAt).map((rdoc) => ({
...pick(rdoc, [
'compilerTexts', 'judgeTexts', 'testCases', 'subtasks',
'score', 'time', 'memory', 'status', 'judgeAt', 'judger',
]),
rid: rdoc._id,
_id: new ObjectId(),
})));
if (rdocs.length) {
await RecordModel.collHistory.insertMany(rdocs.map((rdoc) => ({
...pick(rdoc, [
'compilerTexts', 'judgeTexts', 'testCases', 'subtasks',
'score', 'time', 'memory', 'status', 'judgeAt', 'judger',
]),
rid: rdoc._id,
_id: new ObjectId(),
})));
}
return RecordModel.update(domainId, rid, upd);
}