mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: update to mongodb5 (#514)
This commit is contained in:
1 parent
5a02010120
commit
0685b88066
59 files changed
+610
-601
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import AnsiUp from 'ansi_up';
|
||||
import { moment, ObjectID } from 'hydrooj';
|
||||
import { moment, ObjectId } from 'hydrooj';
|
||||
|
||||
export { size, formatSeconds } from 'hydrooj';
|
||||
|
||||
@@ -10,10 +10,10 @@ export function ansiToHtml(str: string, whiteToBlack = true) {
|
||||
return whiteToBlack ? res.replace(/style="color:rgb\(255,255,255\)"/g, 'style="color:black"') : res;
|
||||
}
|
||||
|
||||
export function datetimeSpan(dt: Date | ObjectID, relative = true, format = 'YYYY-M-D H:mm:ss', tz = 'Asia/Shanghai') {
|
||||
export function datetimeSpan(dt: Date | ObjectId, relative = true, format = 'YYYY-M-D H:mm:ss', tz = 'Asia/Shanghai') {
|
||||
if (!dt) return 'DATETIME_SPAN_ERROR';
|
||||
if (dt instanceof ObjectID) dt = dt.getTimestamp();
|
||||
else if (typeof dt === 'string' && ObjectID.isValid(dt)) dt = new Date(new ObjectID(dt).generationTime * 1000);
|
||||
if (dt instanceof ObjectId) dt = dt.getTimestamp();
|
||||
else if (typeof dt === 'string' && ObjectId.isValid(dt)) dt = new ObjectId(dt).getTimestamp();
|
||||
else if (typeof dt === 'number' || typeof dt === 'string') dt = new Date(dt);
|
||||
return '<span class="time{0}" data-timestamp="{1}">{2}</span>'.format(
|
||||
relative ? ' relative' : '',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable global-require */
|
||||
import {
|
||||
ContestModel, Context, Handler, ObjectID, param, PERM, PRIV, ProblemModel, Schema,
|
||||
ContestModel, Context, Handler, ObjectId, param, PERM, PRIV, ProblemModel, Schema,
|
||||
SettingModel, SystemModel, SystemSettings, Types, UserModel,
|
||||
} from 'hydrooj';
|
||||
import convert from 'schemastery-jsonschema';
|
||||
@@ -106,7 +106,7 @@ class RichMediaHandler extends Handler {
|
||||
async renderContest(domainId, payload) {
|
||||
const cur = payload.domainId ? await UserModel.getById(payload.domainId, this.user._id) : this.user;
|
||||
const tdoc = cur.hasPerm(PERM.PERM_VIEW | PERM.PERM_VIEW_CONTEST)
|
||||
? await ContestModel.get(payload.domainId || domainId, new ObjectID(payload.id))
|
||||
? await ContestModel.get(payload.domainId || domainId, new ObjectId(payload.id))
|
||||
: null;
|
||||
if (tdoc) return await this.renderHTML('partials/contest.html', { tdoc });
|
||||
return '';
|
||||
@@ -115,7 +115,7 @@ class RichMediaHandler extends Handler {
|
||||
async renderHomework(domainId, payload) {
|
||||
const cur = payload.domainId ? await UserModel.getById(payload.domainId, this.user._id) : this.user;
|
||||
const tdoc = cur.hasPerm(PERM.PERM_VIEW | PERM.PERM_VIEW_HOMEWORK)
|
||||
? await ContestModel.get(payload.domainId || domainId, new ObjectID(payload.id))
|
||||
? await ContestModel.get(payload.domainId || domainId, new ObjectId(payload.id))
|
||||
: null;
|
||||
if (tdoc) return await this.renderHTML('partials/homework.html', { tdoc });
|
||||
return '';
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi_up": "^5.1.0",
|
||||
"esbuild": "0.16.16",
|
||||
"esbuild": "0.17.10",
|
||||
"fs-extra": "^11.1.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"jsesc": "^3.0.2",
|
||||
|
||||
Reference in new issue
Block a user