perf: 실시간 접속 확인에서 불필요한 context 조회를 제거

This commit is contained in:
2026-08-16 17:53:25 +00:00
parent dd2ae20167
commit aa51f1b7d9
8 changed files with 148 additions and 78 deletions
@@ -2,7 +2,11 @@ import assert from 'node:assert/strict';
import test from 'node:test';
import { createEmptyRealtimeReadModelChanges, createEmptyRealtimeReadModelInvalidation } from '@sammo-ts/common';
import { createMergedReadModelRefreshQueue, resolveDashboardRefreshPlan } from '../src/utils/dashboardReadModel.ts';
import {
createMergedReadModelRefreshQueue,
resolveDashboardContextBundleInclude,
resolveDashboardRefreshPlan,
} from '../src/utils/dashboardReadModel.ts';
void test('last-turn-time-only events do not schedule any dashboard query', () => {
const plan = resolveDashboardRefreshPlan(createEmptyRealtimeReadModelChanges(), {
@@ -170,6 +174,30 @@ void test('targets a submitted survey projection to its own general', () => {
assert.equal(resolveDashboardRefreshPlan(changes, { generalId: 8, cityId: 3, nationId: 2 }).frontStatus, false);
});
void test('keeps the access bundle projection-free for map, records, and front-status-only plans', () => {
for (const slice of ['map', 'records', 'frontStatus'] as const) {
const plan = { ...createEmptyRealtimeReadModelInvalidation(), [slice]: true };
assert.deepEqual(resolveDashboardContextBundleInclude(plan), {
context: false,
commandTable: false,
boardAccess: false,
});
}
});
void test('selects only the requested context bundle projections', () => {
const plan = {
...createEmptyRealtimeReadModelInvalidation(),
context: true,
commands: true,
};
assert.deepEqual(resolveDashboardContextBundleInclude(plan), {
context: true,
commandTable: true,
boardAccess: false,
});
});
void test('merges browser-safe boolean invalidations and starts at most once per interval', async () => {
let nowMs = 0;
let nextTimerId = 1;