mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
core: fix level & bus event payload
This commit is contained in:
1 parent
878bcbc262
commit
87d8dce528
3 files changed
+7
-6
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.23.4",
|
||||
"version": "2.23.5",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -110,13 +110,11 @@ export async function calcLevel(domainId: string, report: Function) {
|
||||
report({ message: 'Updating users levelled {0}'.format(levels[i][0]) });
|
||||
const query: FilterQuery<Udoc> = {
|
||||
domainId,
|
||||
$and: [{ rank: { $lte: levels[i][1] } }],
|
||||
$and: [{ rank: { $lte: (levels[i][1] * rank) / 100 } }],
|
||||
};
|
||||
if (i < levels.length - 1) query.$and.push({ rank: { $gt: levels[i + 1][1] } });
|
||||
if (i < levels.length - 1) query.$and.push({ rank: { $gt: (levels[i + 1][1] * rank) / 100 } });
|
||||
bulk.find(query).update({ $set: { level: levels[i][0] } });
|
||||
}
|
||||
const i = levels.length - 1;
|
||||
bulk.find({ domainId, rank: { $lte: levels[i][1] } }).update({ $set: { level: levels[i][0] } });
|
||||
await bulk.execute();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import cluster from 'cluster';
|
||||
import type { Db, FilterQuery, OnlyFieldsOfType } from 'mongodb';
|
||||
import serialize from 'serialize-javascript';
|
||||
import { argv } from 'yargs';
|
||||
import type { Handler } from './server';
|
||||
import { Logger } from '../logger';
|
||||
@@ -179,13 +180,15 @@ export function boardcast<K extends keyof EventMap>(event: K, ...payload: Parame
|
||||
process.send({
|
||||
event: 'bus',
|
||||
eventName: event,
|
||||
payload,
|
||||
payload: serialize(payload),
|
||||
});
|
||||
} else parallel(event, ...payload);
|
||||
}
|
||||
|
||||
async function messageHandler(worker: cluster.Worker, msg: any) {
|
||||
if (!msg) msg = worker;
|
||||
// eslint-disable-next-line no-eval
|
||||
if (typeof msg.payload === 'string') msg.payload = eval(msg.payload);
|
||||
if (msg.event) {
|
||||
if (msg.event === 'bus') {
|
||||
if (cluster.isMaster) {
|
||||
|
||||
Reference in new issue
Block a user