mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: rename interface props
This commit is contained in:
1 parent
8ea50bfafb
commit
808cb5d4a5
20 files changed
+148
-154
No files matched your search
@@ -6,7 +6,7 @@ import {
|
||||
ContestNotLiveError, ValidationError, ProblemNotFoundError,
|
||||
ContestNotAttendedError, PermissionError,
|
||||
} from '../error';
|
||||
import { Pdoc, Tdoc, User } from '../interface';
|
||||
import { ProblemDoc, Tdoc, User } from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
import { PERM, PRIV } from '../model/builtin';
|
||||
import * as contest from '../model/contest';
|
||||
@@ -240,7 +240,7 @@ class ContestEditHandler extends Handler {
|
||||
|
||||
class ContestProblemHandler extends Handler {
|
||||
tdoc: Tdoc<30 | 60>;
|
||||
pdoc: Pdoc;
|
||||
pdoc: ProblemDoc;
|
||||
tsdoc: any;
|
||||
udoc: User;
|
||||
attended: boolean;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { isSafeInteger } from 'lodash';
|
||||
import { DiscussionNotFoundError, DocumentNotFoundError, PermissionError } from '../error';
|
||||
import { Drdoc, Ddoc, Drrdoc } from '../interface';
|
||||
import { DiscussionReplyDoc, DiscussionDoc, DiscussionTailReplyDoc } from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
import * as system from '../model/system';
|
||||
import user from '../model/user';
|
||||
@@ -23,9 +23,9 @@ export const typeMapper = {
|
||||
};
|
||||
|
||||
class DiscussionHandler extends Handler {
|
||||
ddoc?: Ddoc;
|
||||
drdoc?: Drdoc;
|
||||
drrdoc?: Drrdoc;
|
||||
ddoc?: DiscussionDoc;
|
||||
drdoc?: DiscussionReplyDoc;
|
||||
drrdoc?: DiscussionTailReplyDoc;
|
||||
vnode?: any;
|
||||
|
||||
@param('type', Types.Name, true)
|
||||
@@ -214,7 +214,7 @@ class DiscussionDetailHandler extends DiscussionHandler {
|
||||
await this.limitRate('add_discussion', 3600, 60);
|
||||
// Notify related users
|
||||
await discussion.addReply(domainId, did, this.user._id, content, this.request.ip);
|
||||
const replies: Drdoc[] = await discussion.getMultiReply(domainId, did).toArray();
|
||||
const replies: DiscussionReplyDoc[] = await discussion.getMultiReply(domainId, did).toArray();
|
||||
const uids = new Set(replies.map((drdoc) => drdoc.owner));
|
||||
uids.delete(this.user._id);
|
||||
const str = JSON.stringify({ message: '{0} replied to discussion {1}/{2}.', params: [this.user._id, domainId, did] });
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
NotFoundError, UserNotFoundError, PermissionError,
|
||||
DomainAlreadyExistsError, ValidationError, BlacklistedError,
|
||||
} from '../error';
|
||||
import { Mdoc, Setting, DomainDoc } from '../interface';
|
||||
import { MessageDoc, Setting, DomainDoc } from '../interface';
|
||||
import * as bus from '../service/bus';
|
||||
import {
|
||||
Route, Connection, Handler, ConnectionHandler, param, Types,
|
||||
@@ -399,7 +399,7 @@ class HomeMessagesConnectionHandler extends ConnectionHandler {
|
||||
this.dispose = bus.on('user/message', this.onMessageReceived.bind(this));
|
||||
}
|
||||
|
||||
async onMessageReceived(uid: number, mdoc: Mdoc) {
|
||||
async onMessageReceived(uid: number, mdoc: MessageDoc) {
|
||||
if (uid !== this.user._id) return;
|
||||
const udoc = await user.getById(this.domainId, mdoc.from);
|
||||
udoc.avatarUrl = avatar(udoc.avatar, 64);
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
ValidationError, HomeworkNotLiveError, ProblemNotFoundError,
|
||||
HomeworkNotAttendedError,
|
||||
} from '../error';
|
||||
import { PenaltyRules, Tdoc, Pdoc } from '../interface';
|
||||
import { PenaltyRules, Tdoc, ProblemDoc } from '../interface';
|
||||
import {
|
||||
Route, Handler, Types, param,
|
||||
} from '../service/server';
|
||||
@@ -118,7 +118,7 @@ class HomeworkDetailHandler extends Handler {
|
||||
|
||||
class HomeworkDetailProblemHandler extends Handler {
|
||||
tdoc: Tdoc<60>;
|
||||
pdoc: Pdoc;
|
||||
pdoc: ProblemDoc;
|
||||
tsdoc: any;
|
||||
|
||||
@param('tid', Types.ObjectID)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { JudgeResultBody, Rdoc, TestCase } from '../interface';
|
||||
import { JudgeResultBody, RecordDoc, TestCase } from '../interface';
|
||||
import { sleep } from '../utils';
|
||||
import { Logger } from '../logger';
|
||||
import difficultyAlgorithm from '../lib/difficulty';
|
||||
@@ -20,7 +20,7 @@ import { updateJudge } from '../service/monitor';
|
||||
|
||||
const logger = new Logger('judge');
|
||||
|
||||
async function _postJudge(rdoc: Rdoc) {
|
||||
async function _postJudge(rdoc: RecordDoc) {
|
||||
if (typeof rdoc.input === 'string') return;
|
||||
const accept = rdoc.status === builtin.STATUS.STATUS_ACCEPTED;
|
||||
const updated = await problem.updateStatus(rdoc.domainId, rdoc.pid, rdoc.uid, rdoc._id, rdoc.status, rdoc.score);
|
||||
@@ -45,7 +45,7 @@ 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: Partial<Rdoc> = {};
|
||||
const $set: Partial<RecordDoc> = {};
|
||||
const $push: any = {};
|
||||
if (body.case) {
|
||||
const c: TestCase = {
|
||||
@@ -77,7 +77,7 @@ 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: Partial<Rdoc> = {};
|
||||
const $set: Partial<RecordDoc> = {};
|
||||
const $push: any = {};
|
||||
const $unset: any = { progress: '' };
|
||||
if (body.message) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
ForbiddenError,
|
||||
} from '../error';
|
||||
import {
|
||||
Pdoc, User, Rdoc, PathComponent, ProblemStatusDoc,
|
||||
ProblemDoc, User, RecordDoc, PathComponent, ProblemStatusDoc,
|
||||
} from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
import { isPid } from '../lib/validator';
|
||||
@@ -61,7 +61,7 @@ export class ProblemMainHandler extends ProblemHandler {
|
||||
async get(domainId: string, page = 1, q = '', category = []) {
|
||||
this.response.template = 'problem_main.html';
|
||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||
const query: FilterQuery<Pdoc> = {};
|
||||
const query: FilterQuery<ProblemDoc> = {};
|
||||
let psdict = {};
|
||||
const path: PathComponent[] = [
|
||||
['Hydro', 'homepage'],
|
||||
@@ -161,7 +161,7 @@ export class ProblemMainHandler extends ProblemHandler {
|
||||
export class ProblemRandomHandler extends ProblemHandler {
|
||||
@param('category', Types.Name, true, null, parseCategory)
|
||||
async get(domainId: string, category: string[] = []) {
|
||||
const q: FilterQuery<Pdoc> = category.length ? { $and: [] } : {};
|
||||
const q: FilterQuery<ProblemDoc> = category.length ? { $and: [] } : {};
|
||||
for (const tag of category) q.$and.push({ tag });
|
||||
if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) q.hidden = false;
|
||||
await bus.serial('problem/list', q, this);
|
||||
@@ -172,7 +172,7 @@ export class ProblemRandomHandler extends ProblemHandler {
|
||||
}
|
||||
}
|
||||
|
||||
export interface PdocWithPsdoc extends Pdoc {
|
||||
export interface PdocWithPsdoc extends ProblemDoc {
|
||||
psdoc?: ProblemStatusDoc
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ export class ProblemPretestConnectionHandler extends ConnectionHandler {
|
||||
this.dispose = bus.on('record/change', this.onRecordChange.bind(this));
|
||||
}
|
||||
|
||||
async onRecordChange(rdoc: Rdoc) {
|
||||
async onRecordChange(rdoc: RecordDoc) {
|
||||
if (
|
||||
rdoc.uid !== this.user._id
|
||||
|| rdoc.pid.toString() !== this.pid
|
||||
@@ -366,7 +366,7 @@ export class ProblemEditHandler extends ProblemManageHandler {
|
||||
newPid: string = '', hidden = false, tag: string[] = [],
|
||||
) {
|
||||
if (newPid !== this.pdoc.pid && await problem.get(domainId, newPid)) throw new BadRequestError('new pid exists');
|
||||
const $update: Partial<Pdoc> = {
|
||||
const $update: Partial<ProblemDoc> = {
|
||||
title, content, pid: newPid, hidden, tag: tag ?? [],
|
||||
};
|
||||
let pdoc = await problem.get(domainId, pid);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import { ContestNotFoundError, PermissionError, RecordNotFoundError } from '../error';
|
||||
import { Rdoc } from '../interface';
|
||||
import { RecordDoc } from '../interface';
|
||||
import { PERM, STATUS, PRIV } from '../model/builtin';
|
||||
import * as system from '../model/system';
|
||||
import problem from '../model/problem';
|
||||
@@ -24,7 +24,7 @@ class RecordListHandler extends Handler {
|
||||
@param('allDomain', Types.Boolean, true)
|
||||
async get(domainId: string, page = 1, pid?: string, tid?: ObjectID, uidOrName?: string, status?: number, all = false) {
|
||||
this.response.template = 'record_main.html';
|
||||
const q: FilterQuery<Rdoc> = { 'contest.tid': tid, hidden: false };
|
||||
const q: FilterQuery<RecordDoc> = { 'contest.tid': tid, hidden: false };
|
||||
if (tid) {
|
||||
const tdoc = await contest.get(domainId, tid, -1);
|
||||
if (!tdoc) throw new ContestNotFoundError(domainId, pid);
|
||||
@@ -178,7 +178,7 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
||||
if (this.dispose) this.dispose();
|
||||
}
|
||||
|
||||
async onRecordChange(rdoc: Rdoc) {
|
||||
async onRecordChange(rdoc: RecordDoc) {
|
||||
if (rdoc.input) return;
|
||||
if (rdoc.contest && rdoc.contest.tid.toString() !== this.tid) return;
|
||||
if (rdoc.domainId !== this.domainId) return;
|
||||
@@ -212,7 +212,7 @@ class RecordDetailConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
async onRecordChange(rdoc: Rdoc, $set?: any, $push?: any) {
|
||||
async onRecordChange(rdoc: RecordDoc, $set?: any, $push?: any) {
|
||||
if (rdoc._id.toString() !== this.rid) return;
|
||||
// TODO: frontend doesn't support incremental update
|
||||
// if ($set) this.send({ $set, $push });
|
||||
|
||||
@@ -12,7 +12,7 @@ import user from '../model/user';
|
||||
import oauth from '../model/oauth';
|
||||
import token from '../model/token';
|
||||
import record from '../model/record';
|
||||
import problem, { Pdoc } from '../model/problem';
|
||||
import problem, { ProblemDoc } from '../model/problem';
|
||||
import task from '../model/task';
|
||||
import * as system from '../model/system';
|
||||
import { PERM, PRIV } from '../model/builtin';
|
||||
@@ -196,7 +196,7 @@ class UserDetailHandler extends Handler {
|
||||
1,
|
||||
100,
|
||||
)
|
||||
: [[], 0, 0] as [Pdoc[], number, number],
|
||||
: [[], 0, 0] as [ProblemDoc[], number, number],
|
||||
]);
|
||||
const pdict = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)
|
||||
? await problem.getList(
|
||||
|
||||
Reference in new issue
Block a user