mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
typings fix
This commit is contained in:
1 parent
765188d321
commit
9ef4e85b4b
4 files changed
+16
-11
No files matched your search
@@ -6,7 +6,9 @@ import * as document from './document';
|
||||
import domain from './domain';
|
||||
import { buildProjection } from '../utils';
|
||||
import type { ProblemStatusDoc, Pdict, Document } from '../interface';
|
||||
import { ArrayKeys, NumberKeys, Projection } from '../typeutils';
|
||||
import {
|
||||
ArrayKeys, MaybeArray, NumberKeys, Projection,
|
||||
} from '../typeutils';
|
||||
import { ProblemNotFoundError, ValidationError } from '../error';
|
||||
import storage from '../service/storage';
|
||||
import * as bus from '../service/bus';
|
||||
@@ -149,7 +151,7 @@ export class ProblemModel {
|
||||
const names = (name instanceof Array) ? name : [name];
|
||||
await storage.del(names.map((t) => `problem/${domainId}/${pid}/testdata/${t}`));
|
||||
await ProblemModel.pull(domainId, pid, 'data', names);
|
||||
await bus.emit('problem/delTestdata', domainId, pid, name);
|
||||
await bus.emit('problem/delTestdata', domainId, pid, names);
|
||||
}
|
||||
|
||||
static async addAdditionalFile(domainId: string, pid: number, name: string, f: Readable | Buffer | string) {
|
||||
@@ -164,11 +166,11 @@ export class ProblemModel {
|
||||
await bus.emit('problem/addAdditionalFile', domainId, pid, name, payload);
|
||||
}
|
||||
|
||||
static async delAdditionalFile(domainId: string, pid: number, name: string | string[]) {
|
||||
static async delAdditionalFile(domainId: string, pid: number, name: MaybeArray<string>) {
|
||||
const names = (name instanceof Array) ? name : [name];
|
||||
await storage.del(names.map((t) => `problem/${domainId}/${pid}/additional_file/${t}`));
|
||||
await ProblemModel.pull(domainId, pid, 'additional_file', names);
|
||||
await bus.emit('problem/delAdditionalFile', domainId, pid, name);
|
||||
await bus.emit('problem/delAdditionalFile', domainId, pid, names);
|
||||
}
|
||||
|
||||
static async random(domainId: string, query: FilterQuery<Pdoc>): Promise<string | null> {
|
||||
@@ -255,7 +257,7 @@ ProblemModel.extend((docId, pid) => ({
|
||||
data: [],
|
||||
additional_file: [],
|
||||
hidden: true,
|
||||
config: {},
|
||||
config: '',
|
||||
acMsg: '',
|
||||
difficulty: 0,
|
||||
}));
|
||||
|
||||
@@ -79,10 +79,10 @@ export interface EventMap extends Record<string, any> {
|
||||
'problem/list': (query: FilterQuery<Pdoc>, handler: any) => VoidReturn
|
||||
'problem/get': (doc: Pdoc, handler: any) => VoidReturn
|
||||
'problem/delete': (domainId: string, docId: number) => VoidReturn
|
||||
'problem/addTestdata': (domainId: string, docId: number, name: string, payload: FileInfo) => VoidReturn
|
||||
'problem/delTestdata': (domainId: string, docId: number, name: string) => VoidReturn
|
||||
'problem/addAdditionalFile': (domainId: string, docId: number, name: string, payload: FileInfo) => VoidReturn
|
||||
'problem/delAdditionalFile': (domainId: string, docId: number, name: string) => VoidReturn
|
||||
'problem/addTestdata': (domainId: string, docId: number, name: string, payload: Omit<FileInfo, '_id'>) => VoidReturn
|
||||
'problem/delTestdata': (domainId: string, docId: number, name: string[]) => VoidReturn
|
||||
'problem/addAdditionalFile': (domainId: string, docId: number, name: string, payload: Omit<FileInfo, '_id'>) => VoidReturn
|
||||
'problem/delAdditionalFile': (domainId: string, docId: number, name: string[]) => VoidReturn
|
||||
|
||||
'training/list': (query: FilterQuery<TrainingDoc>, handler: any) => VoidReturn
|
||||
'training/get': (tdoc: TrainingDoc, handler: any) => VoidReturn
|
||||
|
||||
@@ -138,7 +138,10 @@ const scripts: UpgradeScript[] = [
|
||||
storage.list(`problem/${pdoc.domainId}/${pdoc.docId}/testdata/`),
|
||||
storage.list(`problem/${pdoc.domainId}/${pdoc.docId}/additional_file/`),
|
||||
]);
|
||||
await problem.edit(pdoc.domainId, pdoc.docId, { data, additional_file });
|
||||
await problem.edit(
|
||||
pdoc.domainId, pdoc.docId,
|
||||
{ data: data.map((d) => ({ ...d, _id: d.name })), additional_file: additional_file.map((d) => ({ ...d, _id: d.name })) },
|
||||
);
|
||||
if (!pdoc.config) return;
|
||||
if (data.map((d) => d.name).includes('config.yaml')) return;
|
||||
const cfg = yaml.dump(pdoc.config);
|
||||
|
||||
@@ -100,7 +100,7 @@ export async function run({
|
||||
await problem.edit('system', pid, {
|
||||
nAccept: pdoc.accepted,
|
||||
nSubmit: pdoc.submit,
|
||||
config: { time: `${pdoc.time_limit}s`, memory: `${pdoc.memory_limit}m` },
|
||||
config: `time: ${pdoc.time_limit}s\nmemory: ${pdoc.memory_limit}m`,
|
||||
owner: uidMap[cdoc[0].user_id],
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user