mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: 修复acm比赛管理员重测会计入多个罚时的问题
This commit is contained in:
1 parent
16613a6970
commit
7371b0c83c
4 files changed
+19
-10
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.14.6",
|
"version": "2.14.7",
|
||||||
"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",
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ export async function updateStatus(
|
|||||||
const tdoc = await get(domainId, tid, type);
|
const tdoc = await get(domainId, tid, type);
|
||||||
const tsdoc = await document.revPushStatus(domainId, type, tid, uid, 'journal', {
|
const tsdoc = await document.revPushStatus(domainId, type, tid, uid, 'journal', {
|
||||||
rid, pid, accept, score,
|
rid, pid, accept, score,
|
||||||
});
|
}, 'rid');
|
||||||
if (!tsdoc.attend) throw new ContestNotAttendedError(tid, uid);
|
if (!tsdoc.attend) throw new ContestNotAttendedError(tid, uid);
|
||||||
const journal = _getStatusJournal(tsdoc);
|
const journal = _getStatusJournal(tsdoc);
|
||||||
const stats = RULES[tdoc.rule].stat(tdoc, journal);
|
const stats = RULES[tdoc.rule].stat(tdoc, journal);
|
||||||
|
|||||||
@@ -331,13 +331,20 @@ export async function incStatus<T extends keyof DocStatusType>(
|
|||||||
|
|
||||||
export async function revPushStatus<T extends keyof DocStatusType>(
|
export async function revPushStatus<T extends keyof DocStatusType>(
|
||||||
domainId: string, docType: T, docId: DocStatusType[T]['docId'], uid: number,
|
domainId: string, docType: T, docId: DocStatusType[T]['docId'], uid: number,
|
||||||
key: ArrayKeys<DocStatusType[T]>, value: any,
|
key: ArrayKeys<DocStatusType[T]>, value: any, id = '_id',
|
||||||
): Promise<DocStatusType[T]> {
|
): Promise<DocStatusType[T]> {
|
||||||
const res = await collStatus.findOneAndUpdate(
|
let res = await collStatus.findOneAndUpdate(
|
||||||
{ domainId, docType, docId, uid },
|
{ domainId, docType, docId, uid, [`${key}.${id}`]: value[id] },
|
||||||
{ $push: { [key]: value }, $inc: { rev: 1 } },
|
{ $set: { [`${key}.$`]: value }, $inc: { rev: 1 } },
|
||||||
{ upsert: true, returnOriginal: false },
|
{ returnOriginal: false },
|
||||||
);
|
);
|
||||||
|
if (!res.value) {
|
||||||
|
res = await collStatus.findOneAndUpdate(
|
||||||
|
{ domainId, docType, docId, uid },
|
||||||
|
{ $push: { [key]: value }, $inc: { rev: 1 } },
|
||||||
|
{ upsert: true, returnOriginal: false },
|
||||||
|
);
|
||||||
|
}
|
||||||
return res.value;
|
return res.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -614,8 +614,10 @@ export class Handler {
|
|||||||
|
|
||||||
async onerror(error: HydroError) {
|
async onerror(error: HydroError) {
|
||||||
if (!error.msg) error.msg = () => error.message;
|
if (!error.msg) error.msg = () => error.message;
|
||||||
console.error(error.msg(), error.params);
|
if (!(error instanceof NotFoundError)) {
|
||||||
console.error(error.stack);
|
console.error(error.msg(), error.params);
|
||||||
|
console.error(error.stack);
|
||||||
|
}
|
||||||
this.response.status = error instanceof UserFacingError ? error.code : 500;
|
this.response.status = error instanceof UserFacingError ? error.code : 500;
|
||||||
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';
|
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
@@ -805,7 +807,7 @@ export class ConnectionHandler {
|
|||||||
async message(message: any) { } // eslint-disable-line
|
async message(message: any) { } // eslint-disable-line
|
||||||
|
|
||||||
onerror(err: HydroError) {
|
onerror(err: HydroError) {
|
||||||
console.error(err);
|
if (!(err instanceof NotFoundError)) console.error(err);
|
||||||
this.send({
|
this.send({
|
||||||
error: {
|
error: {
|
||||||
name: err.name,
|
name: err.name,
|
||||||
|
|||||||
Reference in new issue
Block a user