core: export HomeHandler

This commit is contained in:
undefined committed 2022-03-10 22:18:28 +08:00
1 parent 8bb072a5a4
commit b13bf24031
5 files changed
+6 -6

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.8.2",
"version": "3.8.3",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+2 -2
View File
@@ -20,8 +20,8 @@ function parseParameters(fn: Function) {
.replace(COMMENTS, '')
.replace(ARR, '');
const result = code.slice(code.indexOf('(') + 1, code.indexOf(')'))
.match(/([^,]+)/g).map((i) => i.trim());
return result === null ? [] : result;
.match(/([^,]+)/g)?.map((i) => i.trim());
return result ?? [];
}
async function runScript(name: string, arg: any) {
+1 -1
View File
@@ -58,7 +58,7 @@ class DomainRankHandler extends Handler {
@query('page', Types.PositiveInt, true)
async get(domainId: string, page = 1) {
const [dudocs, upcount, ucount] = await paginate(
domain.getMultiUserInDomain(domainId, { uid: { $gt: 1 } }).sort({ rp: -1 }),
domain.getMultiUserInDomain(domainId, { uid: { $gt: 1 }, rp: { $gt: 0 } }).sort({ rp: -1 }),
page,
100,
);
+1 -1
View File
@@ -30,7 +30,7 @@ import {
const { geoip, useragent } = global.Hydro.lib;
class HomeHandler extends Handler {
export class HomeHandler extends Handler {
uids = new Set<number>();
collectUser(uids: number[]) {
+1 -1
View File
@@ -99,7 +99,7 @@ export const RpTypes: Record<string, RpDef> = {
global.Hydro.model.rp = RpTypes;
export async function calcLevel(domainId: string, report: Function) {
const filter = { rp: { $exists: true } };
const filter = { rp: { $gt: 0 } };
const ducnt = await domain.getMultiUserInDomain(domainId, filter).count();
await domain.setMultiUserInDomain(domainId, {}, { level: 0, rank: null });
if (!ducnt) return;