🐞 fix(初始): pvp排行榜初始问题修复

This commit is contained in:
luying
2023-05-26 11:26:41 +08:00
parent 12c040a7f7
commit 73f470bdbf
2 changed files with 8 additions and 4 deletions

View File

@@ -104,11 +104,14 @@ function getPinusKeyOfFun(fun: SERVER_GROUP_FUN_TYPE) {
export async function getPVPServerGroup() {
let now = nowSeconds();
const servers = await ServerlistModel.findByEnv(pinus.app.get('env'));
const pvpServerGroup = await ServerGroupModel.findByTime(now, SERVER_GROUP_FUN_TYPE.PVP);
let map = new Map<number, number[]>();
for(let { serverId, groupId } of pvpServerGroup) {
for(let server of servers) {
let serverGroup = pvpServerGroup.find(cur => cur.serverId == server.id);
let groupId = serverGroup? serverGroup.groupId: server.groupId;
if(!map.has(groupId)) map.set(groupId, []);
map.get(groupId).push(serverId);
map.get(groupId).push(server.id);
}
return map
}