core: update problem.setStatus logic

This commit is contained in:
undefined committed 2021-05-06 12:33:32 +08:00
1 parent 8779f03d80
commit eb164991a1
3 files changed
+20 -3

No files matched your search

+4 -2
View File
@@ -230,9 +230,11 @@ export class ProblemModel {
domainId: string, pid: number, uid: number,
rid: ObjectID, status: number, score: number,
) {
const res = await document.setIfNotStatus(
const current = await document.getStatus(domainId, document.TYPE_PROBLEM, pid, uid);
const filter: FilterQuery<ProblemStatusDoc> = { rid: { $ne: rid }, score: { $gt: current.score } };
const res = await document.setStatusIfNotCondition(
domainId, document.TYPE_PROBLEM, pid, uid,
'status', status, STATUS.STATUS_ACCEPTED, { rid, score },
filter, { rid, status, score },
);
return !!res;
}