core: 修复nAccept计算异常的问题

pull/56/head
undefined 4 years ago
parent 4652ce86ab
commit 3f78c35359

@ -116,7 +116,6 @@ Click here to chat with me: 点击这里与我聊天
click to add: 点击添加
CLOSE: 关闭
Code blocks: 代码区块
Code copied to clipboard!: 代码已复制到剪贴板!
Code language: 代码语言
Code: 代码
collapse: 收缩

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.17.15",
"version": "2.17.16",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",

@ -18,22 +18,14 @@ const logger = new Logger('judge');
async function _postJudge(rdoc: Rdoc) {
if (typeof rdoc.input === 'string') return;
const accept = rdoc.status === builtin.STATUS.STATUS_ACCEPTED;
const tasks = [];
tasks.push(
problem.inc(rdoc.domainId, rdoc.pid, 'nAccept', 1),
problem.updateStatus(rdoc.domainId, rdoc.pid, rdoc.uid, rdoc._id, rdoc.status),
);
const updated = await problem.updateStatus(rdoc.domainId, rdoc.pid, rdoc.uid, rdoc._id, rdoc.status);
if (rdoc.contest) {
tasks.push(
contest.updateStatus(
rdoc.domainId, rdoc.contest.tid, rdoc.uid,
rdoc._id, rdoc.pid, accept, rdoc.score, rdoc.contest.type,
),
await contest.updateStatus(
rdoc.domainId, rdoc.contest.tid, rdoc.uid,
rdoc._id, rdoc.pid, accept, rdoc.score, rdoc.contest.type,
);
} else {
tasks.push(domain.incUserInDomain(rdoc.domainId, rdoc.uid, 'nAccept', 1));
}
await Promise.all(tasks);
} else if (updated) await domain.incUserInDomain(rdoc.domainId, rdoc.uid, 'nAccept', 1);
if (accept && updated) await problem.inc(rdoc.domainId, rdoc.pid, 'nAccept', 1);
}
export async function next(body: JudgeResultBody) {

@ -306,7 +306,7 @@ export async function setIfNotStatus<T extends keyof DocStatusType, K extends ke
key: K, value: DocStatusType[T][K], ifNot: DocStatusType[T][K], args: Partial<DocStatusType[T]>,
): Promise<DocStatusType[T]> {
const current = await collStatus.findOne({ domainId, docType, docId, uid }) || {};
if (current[key] === ifNot) return current;
if (current[key] === ifNot) return null;
const res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid },
{ $set: { [key]: value, ...args } },

Loading…
Cancel
Save