mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
修复一处类型错误
This commit is contained in:
1 parent
c0489546b8
commit
b5c1f41dd2
15 files changed
+44
-37
No files matched your search
@@ -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