mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
修复一处类型错误
This commit is contained in:
1 parent
c0489546b8
commit
b5c1f41dd2
15 files changed
+44
-37
No files matched your search
+3
-1
@@ -14,8 +14,9 @@ module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['@typescript-eslint'],
|
||||
rules: {
|
||||
camelcase: 'off',
|
||||
'@typescript-eslint/no-dupe-class-members': 'error',
|
||||
'@typescript-eslint/no-unused-vars': 'error',
|
||||
camelcase: 'off',
|
||||
'global-require': 'off',
|
||||
'guard-for-in': 'off',
|
||||
'implicit-arrow-linebreak': 'off',
|
||||
@@ -28,6 +29,7 @@ module.exports = {
|
||||
'max-len': ['warn', 150],
|
||||
'no-bitwise': 'off',
|
||||
'no-console': 'off',
|
||||
'no-dupe-class-members': 'off',
|
||||
'no-extend-native': 'off',
|
||||
'no-inner-declarations': 'off',
|
||||
'no-multi-assign': 'off',
|
||||
|
||||
Vendored
+2
-1
@@ -5,5 +5,6 @@
|
||||
"editor.detectIndentation": false,
|
||||
"editor.tabSize": 4,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.renderWhitespace": "boundary"
|
||||
"editor.renderWhitespace": "boundary",
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
+9
-9
@@ -15,28 +15,28 @@
|
||||
"version": "1.0.0",
|
||||
"license": "AGPL-3.0-only",
|
||||
"devDependencies": {
|
||||
"@shelf/jest-mongodb": "^1.2.2",
|
||||
"@shelf/jest-mongodb": "^1.2.3",
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"@types/jest": "^26.0.10",
|
||||
"@types/node": "^14.6.0",
|
||||
"@types/jest": "^26.0.13",
|
||||
"@types/node": "^14.6.4",
|
||||
"@types/semver": "^7.3.3",
|
||||
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
||||
"@typescript-eslint/parser": "^3.9.1",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"eslint": "^7.7.0",
|
||||
"eslint": "^7.8.1",
|
||||
"eslint-config-airbnb-base": "^14.2.0",
|
||||
"eslint-import-resolver-typescript": "^2.2.1",
|
||||
"eslint-import-resolver-typescript": "^2.3.0",
|
||||
"eslint-plugin-import": "^2.22.0",
|
||||
"globby": "^11.0.1",
|
||||
"jest": "^26.4.1",
|
||||
"jest": "^26.4.2",
|
||||
"latest-version": "^5.1.0",
|
||||
"ora": "^5.0.0",
|
||||
"semver": "^7.3.2",
|
||||
"ts-jest": "^26.2.0",
|
||||
"typescript": "^3.9.7"
|
||||
"ts-jest": "^26.3.0",
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-extra": "^9.0.1",
|
||||
"yargs": "^15.4.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
"lodash": "^4.17.20",
|
||||
"p-queue": "^6.6.1",
|
||||
"shell-quote": "^1.7.2",
|
||||
"systeminformation": "^4.26.10"
|
||||
"systeminformation": "^4.27.3"
|
||||
},
|
||||
"license": "AGPL-3.0-only",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.12.25",
|
||||
"version": "2.12.26",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
@@ -25,13 +25,13 @@
|
||||
"lodash": "^4.17.20",
|
||||
"lru-cache": "^6.0.0",
|
||||
"moment-timezone": "^0.5.31",
|
||||
"mongodb": "^3.6.0",
|
||||
"mongodb": "^3.6.1",
|
||||
"nodemailer": "^6.4.10",
|
||||
"ps-list": "^7.2.0",
|
||||
"serialize-javascript": "^4.0.0",
|
||||
"sockjs": "^0.3.20",
|
||||
"superagent": "^6.0.0",
|
||||
"systeminformation": "^4.26.10",
|
||||
"superagent": "^6.1.0",
|
||||
"systeminformation": "^4.27.3",
|
||||
"yargs": "^15.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -42,9 +42,9 @@
|
||||
"@types/koa-morgan": "^1.0.4",
|
||||
"@types/koa-router": "^7.4.1",
|
||||
"@types/koa-static-cache": "^5.1.0",
|
||||
"@types/lodash": "^4.14.158",
|
||||
"@types/lodash": "^4.14.161",
|
||||
"@types/lru-cache": "^5.1.0",
|
||||
"@types/mongodb": "^3.5.26",
|
||||
"@types/mongodb": "^3.5.27",
|
||||
"@types/nodemailer": "^6.4.0",
|
||||
"@types/serialize-javascript": "^4.0.0",
|
||||
"@types/sockjs": "^0.3.32",
|
||||
|
||||
@@ -177,6 +177,8 @@ class TrainingCreateHandler extends Handler {
|
||||
const pids = training.getPids({ dag });
|
||||
assert(pids.length, new ValidationError('dag'));
|
||||
const pdocs = await problem.getMulti(domainId, {
|
||||
// TODO
|
||||
// @ts-ignore
|
||||
$or: [{ docId: { $in: pids } }, { pid: { $in: pids } }],
|
||||
}).sort('_id', 1).toArray();
|
||||
const existPids = pdocs.map((pdoc) => pdoc.docId);
|
||||
@@ -238,6 +240,8 @@ class TrainingEditHandler extends Handler {
|
||||
const pdocs = await problem.getMulti(domainId, {
|
||||
$or: [
|
||||
{ docId: { $in: pids } },
|
||||
// TODO
|
||||
// @ts-ignore
|
||||
{ pid: { $in: pids } },
|
||||
],
|
||||
}).sort('_id', 1).toArray();
|
||||
|
||||
@@ -274,7 +274,7 @@ export interface Ddoc {
|
||||
docType: number,
|
||||
docId: ObjectID,
|
||||
parentType: number,
|
||||
parentId: ObjectID | number,
|
||||
parentId: ObjectID | number | string,
|
||||
owner: number,
|
||||
title: string,
|
||||
content: string,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import * as problem from './problem';
|
||||
import * as contest from './contest';
|
||||
import * as training from './training';
|
||||
@@ -57,11 +57,11 @@ export function del(domainId: string, did: ObjectID) {
|
||||
]);
|
||||
}
|
||||
|
||||
export function count(domainId: string, query: any) {
|
||||
export function count(domainId: string, query: FilterQuery<Ddoc>) {
|
||||
return document.count(domainId, document.TYPE_DISCUSSION, query);
|
||||
}
|
||||
|
||||
export function getMulti(domainId: string, query: any = {}) {
|
||||
export function getMulti(domainId: string, query: FilterQuery<Ddoc> = {}) {
|
||||
return document.getMulti(domainId, document.TYPE_DISCUSSION, query)
|
||||
.sort({ pin: -1, updateAt: -1 });
|
||||
}
|
||||
@@ -69,15 +69,15 @@ export function getMulti(domainId: string, query: any = {}) {
|
||||
export async function addReply(
|
||||
domainId: string, did: ObjectID, owner: number,
|
||||
content: string, ip: string,
|
||||
): Promise<Drdoc> {
|
||||
const [drdoc] = await Promise.all([
|
||||
): Promise<ObjectID> {
|
||||
const [drid] = await Promise.all([
|
||||
document.add(
|
||||
domainId, content, owner, document.TYPE_DISCUSSION_REPLY,
|
||||
null, document.TYPE_DISCUSSION, did, { ip },
|
||||
),
|
||||
document.incAndSet(domainId, document.TYPE_DISCUSSION, did, 'nReply', 1, { updateAt: new Date() }),
|
||||
]);
|
||||
return drdoc;
|
||||
return drid;
|
||||
}
|
||||
|
||||
export function getReply(domainId: string, drid: ObjectID): Promise<Drdoc | null> {
|
||||
|
||||
@@ -51,7 +51,7 @@ export function getMulti(query: any = {}) {
|
||||
return coll.find(query);
|
||||
}
|
||||
|
||||
export function edit(domainId: string, $set: any) {
|
||||
export function edit(domainId: string, $set: Partial<DomainDoc>) {
|
||||
return coll.updateOne({ _id: domainId }, { $set });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import * as user from './user';
|
||||
import { Mdoc } from '../interface';
|
||||
import * as db from '../service/db';
|
||||
@@ -35,7 +35,7 @@ export async function getByUser(uid: number): Promise<Mdoc[]> {
|
||||
return await coll.find({ $or: [{ from: uid }, { to: uid }] }).sort('_id', 1).toArray();
|
||||
}
|
||||
|
||||
export async function getMany(query: any, sort: any, page: number, limit: number): Promise<Mdoc[]> {
|
||||
export async function getMany(query: FilterQuery<Mdoc>, sort: any, page: number, limit: number): Promise<Mdoc[]> {
|
||||
return await coll.find(query).sort(sort)
|
||||
.skip((page - 1) * limit).limit(limit)
|
||||
.toArray();
|
||||
@@ -54,7 +54,7 @@ export async function del(_id: ObjectID) {
|
||||
return await coll.deleteOne({ _id });
|
||||
}
|
||||
|
||||
export function count(query: any) {
|
||||
export function count(query: FilterQuery<Mdoc> = {}) {
|
||||
return coll.find(query).count();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ export async function get(
|
||||
return pdoc;
|
||||
}
|
||||
|
||||
export function getMulti(domainId: string, query: object) {
|
||||
export function getMulti(domainId: string, query: FilterQuery<Pdoc>) {
|
||||
return document.getMulti(domainId, document.TYPE_PROBLEM, query);
|
||||
}
|
||||
|
||||
@@ -89,11 +89,11 @@ export function inc(domainId: string, _id: number, field: string, n: number): Pr
|
||||
return document.inc(domainId, document.TYPE_PROBLEM, _id, field, n);
|
||||
}
|
||||
|
||||
export function count(domainId: string, query: any) {
|
||||
export function count(domainId: string, query: FilterQuery<Pdoc>) {
|
||||
return document.count(domainId, document.TYPE_PROBLEM, query);
|
||||
}
|
||||
|
||||
export async function random(domainId: string, query: any): Promise<string | null> {
|
||||
export async function random(domainId: string, query: FilterQuery<Pdoc>): Promise<string | null> {
|
||||
const cursor = document.getMulti(domainId, document.TYPE_PROBLEM, query);
|
||||
const pcount = await cursor.count();
|
||||
if (pcount) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"hydrooj": "^2.12.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"superagent": "^6.0.0",
|
||||
"superagent": "^6.1.0",
|
||||
"superagent-proxy": "^2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
"hydrooj": "^2.12.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"superagent": "^6.0.0",
|
||||
"superagent": "^6.1.0",
|
||||
"superagent-proxy": "^2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
"hydrooj": "^2.12.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"superagent": "^6.0.0",
|
||||
"superagent": "^6.1.0",
|
||||
"superagent-proxy": "^2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,13 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^3.12.5",
|
||||
"@types/mongodb": "^3.5.26"
|
||||
"@types/mongodb": "^3.5.27"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hydrooj": "^2.12.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-yaml": "^3.14.0",
|
||||
"mongodb": "^3.6.0"
|
||||
"mongodb": "^3.6.1"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user