bug fixes

This commit is contained in:
undefined committed 2025-03-17 07:48:40 +08:00
1 parent 3c65c27911
commit 80d2137cbb
6 files changed
+19 -25

No files matched your search

+8 -4
View File
@@ -234,7 +234,7 @@ export default class RecordModel {
}
static async reset(domainId: string, rid: MaybeArray<ObjectId>, isRejudge: boolean) {
const rids = rid instanceof Array ? rid : [rid];
const rids = Array.isArray(rid) ? rid : [rid];
const upd: any = {
score: 0,
status: STATUS.STATUS_WAITING,
@@ -281,7 +281,7 @@ export default class RecordModel {
}
}
export function apply(ctx: Context) {
export async function apply(ctx: Context) {
// Mark problem as deleted
ctx.on('problem/delete', (domainId, docId) => Promise.all([
RecordModel.coll.deleteMany({ domainId, pid: docId }),
@@ -305,7 +305,7 @@ export function apply(ctx: Context) {
}, { upsert: true });
}
});
ctx.on('ready', () => Promise.all([
await Promise.all([
db.ensureIndexes(
RecordModel.coll,
{ key: { domainId: 1, pid: 1 }, name: 'delete' },
@@ -322,6 +322,10 @@ export function apply(ctx: Context) {
{ key: { domainId: 1, pid: 1, uid: 1, memory: 1 }, name: 'memory' },
{ key: { domainId: 1, pid: 1, uid: 1, length: 1 }, name: 'length' },
),
]) as any);
db.ensureIndexes(
RecordModel.collHistory,
{ key: { rid: 1, _id: -1 }, name: 'basic' },
),
]);
}
global.Hydro.model.record = RecordModel;
+5 -5
View File
@@ -7,13 +7,13 @@ import { Context, Service } from '../context';
import { PERM, PRIV } from '../model/builtin';
import { Handler } from './server';
const types: Record<string, Record<string, string>> = {};
const unions: Record<string, string> = {};
const descriptions: Record<string, Record<string, string>> = {};
const types: Record<string, Record<string, string>> = Object.create(null);
const unions: Record<string, string> = Object.create(null);
const descriptions: Record<string, Record<string, string>> = Object.create(null);
const handlers: Record<string, Record<string, any>> = {
Query: {},
Query: Object.create(null),
};
let root: Record<string, any> = {};
let root: Record<string, any> = Object.create(null);
interface ApiContext extends ApiHandler {
[key: string]: any;