mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: rp: filter banned user
This commit is contained in:
1 parent
038036717e
commit
08585bd3e9
2 files changed
+9
-7
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.29.40",
|
||||
"version": "2.29.41",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -6,8 +6,9 @@ import db from '../service/db';
|
||||
import domain from '../model/domain';
|
||||
import * as contest from '../model/contest';
|
||||
import problem from '../model/problem';
|
||||
import UserModel from '../model/user';
|
||||
import record from '../model/record';
|
||||
import { STATUS } from '../model/builtin';
|
||||
import { PRIV, STATUS } from '../model/builtin';
|
||||
import rating from '../lib/rating';
|
||||
import paginate from '../lib/paginate';
|
||||
|
||||
@@ -155,12 +156,13 @@ async function runInDomain(id: string, isSub: boolean, report: Function) {
|
||||
}
|
||||
await domain.setMultiUserInDomain(id, {}, { rp: 1500 });
|
||||
const tasks = [];
|
||||
for (const uid in udict) {
|
||||
const rp = udict[uid] + (deltaudict[uid] || 0);
|
||||
const update: any = { $set: { rp } };
|
||||
if (isSub) update.$push = { ratingHistory: rp };
|
||||
tasks.push(domain.updateUserInDomain(id, +uid, update));
|
||||
async function update(uid: number, rp: number) {
|
||||
const udoc = await UserModel.getById(id, +uid);
|
||||
const $upd: any = { $set: { rp } };
|
||||
if (isSub) $upd.$push = { ratingHistory: rp };
|
||||
if (udoc.hasPriv(PRIV.PRIV_USER_PROFILE)) await domain.updateUserInDomain(id, +uid, $upd);
|
||||
}
|
||||
for (const uid in udict) tasks.push(update(+uid, udict[uid] + (deltaudict[uid] || 0)));
|
||||
await Promise.all(tasks);
|
||||
await calcLevel(id, report);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user