mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
一些优化
优化 Date.prototype.format 修复题目分类解析错误的问题 Interface Tdoc X-Forwarded-For 支持
This commit is contained in:
1 parent
1722fbfaca
commit
82c193b5ee
19 files changed
+289
-182
No files matched your search
@@ -278,7 +278,7 @@ export const BUILTIN_USERS = [
|
||||
regip: '127.0.0.1',
|
||||
loginat: new Date(0),
|
||||
loginip: '127.0.0.1',
|
||||
priv: PRIV.PRIV_NONE,
|
||||
priv: PRIV.PRIV_REGISTER_USER,
|
||||
},
|
||||
{
|
||||
_id: 1,
|
||||
|
||||
@@ -390,8 +390,10 @@ export async function edit(
|
||||
return await document.set(domainId, type, tid, $set);
|
||||
}
|
||||
|
||||
export async function get(domainId: string, tid: ObjectID, type = document.TYPE_CONTEST) {
|
||||
let tdoc;
|
||||
export async function get(
|
||||
domainId: string, tid: ObjectID, type = document.TYPE_CONTEST,
|
||||
) {
|
||||
let tdoc: Tdoc;
|
||||
if (type === -1) {
|
||||
tdoc = await document.get(domainId, document.TYPE_CONTEST, tid);
|
||||
if (!tdoc) tdoc = await document.get(domainId, document.TYPE_HOMEWORK, tid);
|
||||
@@ -535,7 +537,7 @@ export function getMulti(domainId: string, query = {}, type = document.TYPE_CONT
|
||||
|
||||
export async function getAndListStatus(
|
||||
domainId: string, tid: ObjectID, docType = document.TYPE_CONTEST,
|
||||
) {
|
||||
): Promise<[Tdoc, any[]]> {
|
||||
// TODO(iceboy): projection, pagination.
|
||||
const tdoc = await get(domainId, tid, docType);
|
||||
const tsdocs = await document.getMultiStatus(domainId, docType, { docId: tid })
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ObjectID, FilterQuery } from 'mongodb';
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { STATUS } from './builtin';
|
||||
import * as file from './file';
|
||||
import * as document from './document';
|
||||
@@ -47,8 +47,6 @@ export async function get(
|
||||
): Promise<Pdoc> {
|
||||
if (typeof pid !== 'number') {
|
||||
if (!Number.isNaN(parseInt(pid, 10))) pid = parseInt(pid, 10);
|
||||
else if (doThrow) throw new ProblemNotFoundError(domainId, pid);
|
||||
else return null;
|
||||
}
|
||||
const pdoc = Number.isInteger(pid)
|
||||
? await document.get(domainId, document.TYPE_PROBLEM, pid)
|
||||
@@ -87,11 +85,11 @@ export function inc(domainId: string, _id: number, field: string, n: number) {
|
||||
return document.inc(domainId, document.TYPE_PROBLEM, _id, field, n);
|
||||
}
|
||||
|
||||
export function count<T>(domainId: string, query: FilterQuery<T>) {
|
||||
export function count(domainId: string, query: any) {
|
||||
return document.count(domainId, document.TYPE_PROBLEM, query);
|
||||
}
|
||||
|
||||
export async function random<T>(domainId: string, query: FilterQuery<T>) {
|
||||
export async function random(domainId: string, query: any) {
|
||||
const cursor = document.getMulti(domainId, document.TYPE_PROBLEM, query);
|
||||
const pcount = await cursor.count();
|
||||
if (pcount) {
|
||||
|
||||
@@ -116,6 +116,7 @@ SystemSetting(
|
||||
Setting('setting_server', 'server.host', null, null, 'text', 'Server Host'),
|
||||
Setting('setting_server', 'server.url', null, null, 'text', 'Server BaseURL'),
|
||||
Setting('setting_server', 'server.port', null, 8888, 'number', 'Server Port'),
|
||||
Setting('setting_server', 'server.xff', null, null, 'text', 'IP Header'),
|
||||
Setting('setting_server', 'server.log', null, false, 'boolean', 'Disable Access Log'),
|
||||
Setting('setting_ui', 'ui.header', null, null, 'text', 'Header Logo'),
|
||||
Setting('setting_ui', 'ui.headerBackground', null, null, 'text', 'Header Background'),
|
||||
|
||||
Reference in new issue
Block a user