fix: 실제 행동 기준으로 접속 중 국가를 집계

This commit is contained in:
2026-08-19 14:14:12 +00:00
parent daf98722de
commit 830833ebc6
11 changed files with 295 additions and 69 deletions
+3 -2
View File
@@ -810,7 +810,7 @@ export const generalRouter = router({
const [onlineAccess, ownNation, latestVote] = await Promise.all([
ctx.db.generalAccessLog.findMany({
where: {
lastRefresh: {
lastActionAt: {
gte: scoreStartedAt,
},
},
@@ -868,8 +868,9 @@ export const generalRouter = router({
onlineByNation.set(general.nationId, bucket);
}
const onlineNations = [...onlineByNation.entries()]
.filter(([nationId]) => nationId > 0)
.sort((left, right) => right[1].length - left[1].length || left[0] - right[0])
.map(([nationId]) => `${nationId === 0 ? '재야' : (nationNames.get(nationId) ?? `세력 ${nationId}`)}`)
.map(([nationId]) => `${nationNames.get(nationId) ?? `세력 ${nationId}`}`)
.join(', ');
const myOnlineGenerals = onlineGenerals
.filter((general) => general.nationId === me.nationId)