mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: sync rdoc.score to psdoc.score
This commit is contained in:
1 parent
fda62809a1
commit
9e94ede71f
5 files changed
+27
-5
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.24.12",
|
"version": "2.24.13",
|
||||||
"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",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ 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 updated = await 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, rdoc.score);
|
||||||
if (rdoc.contest) {
|
if (rdoc.contest) {
|
||||||
await contest.updateStatus(
|
await contest.updateStatus(
|
||||||
rdoc.domainId, rdoc.contest.tid, rdoc.uid,
|
rdoc.domainId, rdoc.contest.tid, rdoc.uid,
|
||||||
|
|||||||
@@ -228,11 +228,11 @@ export class ProblemModel {
|
|||||||
|
|
||||||
static async updateStatus(
|
static async updateStatus(
|
||||||
domainId: string, pid: number, uid: number,
|
domainId: string, pid: number, uid: number,
|
||||||
rid: ObjectID, status: number,
|
rid: ObjectID, status: number, score: number,
|
||||||
) {
|
) {
|
||||||
const res = await document.setIfNotStatus(
|
const res = await document.setIfNotStatus(
|
||||||
domainId, document.TYPE_PROBLEM, pid, uid,
|
domainId, document.TYPE_PROBLEM, pid, uid,
|
||||||
'status', status, STATUS.STATUS_ACCEPTED, { rid },
|
'status', status, STATUS.STATUS_ACCEPTED, { rid, score },
|
||||||
);
|
);
|
||||||
return !!res;
|
return !!res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
|
import { FilterQuery } from 'mongodb';
|
||||||
import type { DomainDoc, Udoc } from './interface';
|
import type { DomainDoc, Udoc } from './interface';
|
||||||
import domain from './model/domain';
|
import domain from './model/domain';
|
||||||
|
import * as document from './model/document';
|
||||||
import user from './model/user';
|
import user from './model/user';
|
||||||
import problem, { Field, Pdoc } from './model/problem';
|
import problem, { Field, Pdoc } from './model/problem';
|
||||||
|
|
||||||
@@ -14,6 +16,16 @@ export async function iterateAllUser(cb: (udoc: Udoc, current?: number, total?:
|
|||||||
for (const i in udocs) await cb(udocs[i], +i, udocs.length);
|
for (const i in udocs) await cb(udocs[i], +i, udocs.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function iterateAllPsdoc(filter: FilterQuery<any>, cb: (psdoc: any) => Promise<any>) {
|
||||||
|
await iterateAllDomain(async ({ _id: domainId }) => {
|
||||||
|
const cursor = document.getMultiStatus(domainId, document.TYPE_PROBLEM, filter);
|
||||||
|
while (await cursor.hasNext()) {
|
||||||
|
const psdoc = await cursor.next();
|
||||||
|
await cb(psdoc);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
interface PartialPdoc extends Pdoc {
|
interface PartialPdoc extends Pdoc {
|
||||||
[key: string]: any,
|
[key: string]: any,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import { Progress } from './ui';
|
|||||||
import { Rdoc } from './interface';
|
import { Rdoc } from './interface';
|
||||||
import { Logger } from './logger';
|
import { Logger } from './logger';
|
||||||
import { streamToBuffer } from './utils';
|
import { streamToBuffer } from './utils';
|
||||||
import { iterateAllDomain, iterateAllProblem, iterateAllUser } from './pipelineUtils';
|
import {
|
||||||
|
iterateAllDomain, iterateAllProblem, iterateAllPsdoc, iterateAllUser,
|
||||||
|
} from './pipelineUtils';
|
||||||
import gridfs from './service/gridfs';
|
import gridfs from './service/gridfs';
|
||||||
import storage from './service/storage';
|
import storage from './service/storage';
|
||||||
import db from './service/db';
|
import db from './service/db';
|
||||||
@@ -21,6 +23,7 @@ import domain from './model/domain';
|
|||||||
import * as document from './model/document';
|
import * as document from './model/document';
|
||||||
import * as system from './model/system';
|
import * as system from './model/system';
|
||||||
import { STATUS } from './model/builtin';
|
import { STATUS } from './model/builtin';
|
||||||
|
import RecordModel from './model/record';
|
||||||
|
|
||||||
const logger = new Logger('upgrade');
|
const logger = new Logger('upgrade');
|
||||||
type UpgradeScript = void | (() => Promise<boolean | void>);
|
type UpgradeScript = void | (() => Promise<boolean | void>);
|
||||||
@@ -317,6 +320,13 @@ const scripts: UpgradeScript[] = [
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
async function _25_26() {
|
||||||
|
await iterateAllPsdoc({ rid: { $exists: true } }, async (psdoc) => {
|
||||||
|
const rdoc = await RecordModel.get(psdoc.domainId, psdoc.rid);
|
||||||
|
await document.setStatus(psdoc.domainId, document.TYPE_PROBLEM, rdoc.pid, rdoc.uid, { score: rdoc.score });
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default scripts;
|
export default scripts;
|
||||||
Reference in new issue
Block a user