mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
移除一些anyscript特性
This commit is contained in:
1 parent
c3ff5856e4
commit
cc62fd3cd7
7 files changed
+97
-19
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.12.7",
|
||||
"version": "2.12.8",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import moment from 'moment-timezone';
|
||||
import { Dictionary } from 'lodash';
|
||||
import {
|
||||
RoleAlreadyExistError, ValidationError, DomainJoinForbiddenError,
|
||||
DomainJoinAlreadyMemberError, InvalidJoinInvitationCodeError,
|
||||
@@ -170,7 +171,7 @@ class DomainRoleHandler extends ManageHandler {
|
||||
@param('role', Types.String)
|
||||
async postAdd(domainId: string, role: string) {
|
||||
const roles = await domain.getRoles(this.domain);
|
||||
const rdict: any = {};
|
||||
const rdict: Dictionary<any> = {};
|
||||
for (const r of roles) rdict[r._id] = r.perm;
|
||||
if (rdict[role]) throw new RoleAlreadyExistError(role);
|
||||
await domain.addRole(domainId, role, rdict.default.perm);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { JudgeResultBody, Rdoc } from '../interface';
|
||||
import { ObjectID, PushOperator, MatchKeysAndValues } from 'mongodb';
|
||||
import { JudgeResultBody, Rdoc, TestCase } from '../interface';
|
||||
import * as record from '../model/record';
|
||||
import * as problem from '../model/problem';
|
||||
import * as builtin from '../model/builtin';
|
||||
@@ -36,14 +36,15 @@ async function _postJudge(rdoc: Rdoc) {
|
||||
export async function next(body: JudgeResultBody) {
|
||||
if (body.rid) body.rid = new ObjectID(body.rid);
|
||||
let rdoc = await record.get(body.domainId, body.rid);
|
||||
const $set: any = {};
|
||||
const $set: Partial<Rdoc> = {};
|
||||
const $push: any = {};
|
||||
if (body.case) {
|
||||
const c: any = {};
|
||||
c.memory = body.case.memory;
|
||||
c.time = body.case.time;
|
||||
c.message = body.case.message;
|
||||
c.status = body.case.status;
|
||||
const c: TestCase = {
|
||||
memory: body.case.memory,
|
||||
time: body.case.time,
|
||||
message: body.case.message,
|
||||
status: body.case.status,
|
||||
};
|
||||
rdoc.testCases.push(c);
|
||||
$push.testCases = c;
|
||||
}
|
||||
@@ -67,9 +68,9 @@ export async function next(body: JudgeResultBody) {
|
||||
export async function end(body: JudgeResultBody) {
|
||||
if (body.rid) body.rid = new ObjectID(body.rid);
|
||||
let rdoc = await record.get(body.domainId, body.rid);
|
||||
const $set: any = {};
|
||||
const $set: Partial<Rdoc> = {};
|
||||
const $push: any = {};
|
||||
const $unset = { progress: '' };
|
||||
const $unset: { progress: '' } = { progress: '' };
|
||||
if (body.message) {
|
||||
rdoc.judgeTexts.push(body.message);
|
||||
$push.judgeTexts = body.message;
|
||||
@@ -80,8 +81,6 @@ export async function end(body: JudgeResultBody) {
|
||||
}
|
||||
if (body.status) $set.status = body.status;
|
||||
if (body.score) $set.score = body.score;
|
||||
if (body.stdout) $set.stdout = body.stdout;
|
||||
if (body.stderr) $set.stderr = body.stderr;
|
||||
if (body.time) $set.time = body.time;
|
||||
if (body.memory) $set.memory = body.memory;
|
||||
$set.judgeAt = new Date();
|
||||
|
||||
@@ -191,10 +191,11 @@ export interface Rdoc {
|
||||
compilerTexts: string[],
|
||||
testCases: TestCase[],
|
||||
rejudged: boolean,
|
||||
judger: string,
|
||||
judger: number,
|
||||
judgeAt: Date,
|
||||
status: number,
|
||||
hidden: boolean,
|
||||
progress?: number,
|
||||
config?: PretestConfig,
|
||||
contest?: ContestInfo,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { ObjectID, Collection } from 'mongodb';
|
||||
import {
|
||||
ObjectID, Collection, UpdateQuery, PushOperator, MatchKeysAndValues, OnlyFieldsOfType,
|
||||
} from 'mongodb';
|
||||
import { Dictionary } from 'lodash';
|
||||
import { STATUS } from './builtin';
|
||||
import * as task from './task';
|
||||
@@ -109,9 +111,11 @@ export function getMulti(domainId: string, query: any) {
|
||||
|
||||
export async function update(
|
||||
domainId: string, _id: ObjectID,
|
||||
$set: any = {}, $push: any = {}, $unset: any = {},
|
||||
$set?: MatchKeysAndValues<Rdoc>,
|
||||
$push?: PushOperator<Rdoc>,
|
||||
$unset?: OnlyFieldsOfType<Rdoc, any, true | '' | 1>,
|
||||
): Promise<Rdoc | null> {
|
||||
const $update: any = {};
|
||||
const $update: UpdateQuery<Rdoc> = {};
|
||||
if ($set && Object.keys($set).length) $update.$set = $set;
|
||||
if ($push && Object.keys($push).length) $update.$push = $push;
|
||||
if ($unset && Object.keys($unset).length) $update.$unset = $unset;
|
||||
|
||||
Reference in new issue
Block a user