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

This commit is contained in:
undefined committed 2021-02-22 00:01:33 +08:00
1 parent 4652ce86ab
commit 3f78c35359
4 files changed
+6 -15

No files matched your search

-1
View File
@@ -116,7 +116,6 @@ Click here to chat with me: 点击这里与我聊天
click to add: 点击添加 click to add: 点击添加
CLOSE: 关闭 CLOSE: 关闭
Code blocks: 代码区块 Code blocks: 代码区块
Code copied to clipboard!: 代码已复制到剪贴板!
Code language: 代码语言 Code language: 代码语言
Code: 代码 Code: 代码
collapse: 收缩 collapse: 收缩
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.17.15", "version": "2.17.16",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
+4 -12
View File
@@ -18,22 +18,14 @@ const logger = new Logger('judge');
async function _postJudge(rdoc: Rdoc) { async function _postJudge(rdoc: Rdoc) {
if (typeof rdoc.input === 'string') return; if (typeof rdoc.input === 'string') return;
const accept = rdoc.status === builtin.STATUS.STATUS_ACCEPTED; const accept = rdoc.status === builtin.STATUS.STATUS_ACCEPTED;
const tasks = []; const updated = await problem.updateStatus(rdoc.domainId, rdoc.pid, rdoc.uid, rdoc._id, rdoc.status);
tasks.push(
problem.inc(rdoc.domainId, rdoc.pid, 'nAccept', 1),
problem.updateStatus(rdoc.domainId, rdoc.pid, rdoc.uid, rdoc._id, rdoc.status),
);
if (rdoc.contest) { if (rdoc.contest) {
tasks.push( await contest.updateStatus(
contest.updateStatus(
rdoc.domainId, rdoc.contest.tid, rdoc.uid, rdoc.domainId, rdoc.contest.tid, rdoc.uid,
rdoc._id, rdoc.pid, accept, rdoc.score, rdoc.contest.type, rdoc._id, rdoc.pid, accept, rdoc.score, rdoc.contest.type,
),
); );
} else { } else if (updated) await domain.incUserInDomain(rdoc.domainId, rdoc.uid, 'nAccept', 1);
tasks.push(domain.incUserInDomain(rdoc.domainId, rdoc.uid, 'nAccept', 1)); if (accept && updated) await problem.inc(rdoc.domainId, rdoc.pid, 'nAccept', 1);
}
await Promise.all(tasks);
} }
export async function next(body: JudgeResultBody) { export async function next(body: JudgeResultBody) {
+1 -1
View File
@@ -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]>, key: K, value: DocStatusType[T][K], ifNot: DocStatusType[T][K], args: Partial<DocStatusType[T]>,
): Promise<DocStatusType[T]> { ): Promise<DocStatusType[T]> {
const current = await collStatus.findOne({ domainId, docType, docId, uid }) || {}; 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( const res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid }, { domainId, docType, docId, uid },
{ $set: { [key]: value, ...args } }, { $set: { [key]: value, ...args } },