feat: 플레이 감사 장수 로그를 기수별로 조회

This commit is contained in:
2026-09-16 04:03:14 +00:00
parent 69a61b317c
commit 31c5927449
20 changed files with 437 additions and 21 deletions
+8 -3
View File
@@ -619,7 +619,8 @@ const persistNationBettingOpen = async (
const persistNationBettingFinish = async (
prisma: GamePrisma.TransactionClient,
finish: PendingNationBettingFinish,
recordsFinalized: boolean
recordsFinalized: boolean,
serverId: string | null
): Promise<void> => {
await prisma.$queryRaw`
SELECT id
@@ -752,6 +753,7 @@ const persistNationBettingFinish = async (
if (finishLog) {
await prisma.logEntry.create({
data: {
serverId,
scope: finishLog.scope,
category: finishLog.category,
subType: finishLog.subType ?? null,
@@ -1026,7 +1028,7 @@ const buildDiplomacyUpdate = (
const buildLogCreateData = (
entry: LogEntryDraft,
context: { year: number; month: number; at: Date }
context: { year: number; month: number; at: Date; serverId: string | null }
): TurnEngineLogEntryCreateManyInput | null => {
const record = finalizeLogEntry(entry, {
year: context.year,
@@ -1038,6 +1040,7 @@ const buildLogCreateData = (
}
return {
serverId: context.serverId,
scope: record.scope,
category: record.category,
subType: record.subType ?? null,
@@ -1194,6 +1197,8 @@ export const createDatabaseTurnHooks = async (
})
)?.id ?? 0;
const logContext = {
serverId:
typeof state.meta.serverId === 'string' && state.meta.serverId.trim() ? state.meta.serverId : null,
year: state.currentYear,
month: state.currentMonth,
at: state.lastTurnTime,
@@ -1474,7 +1479,7 @@ export const createDatabaseTurnHooks = async (
await persistNationBettingOpen(prisma, betting);
}
for (const finish of pendingNationBettingFinishes) {
await persistNationBettingFinish(prisma, finish, recordsFinalized);
await persistNationBettingFinish(prisma, finish, recordsFinalized, logContext.serverId);
}
const meta = asRecord(state.meta);
@@ -669,7 +669,9 @@ const appendSelectionLogs = async (options: {
generalText: string;
globalText: string;
}): Promise<void> => {
const serverId = asRecord(options.worldState.meta).serverId;
const common = {
serverId: typeof serverId === 'string' && serverId.trim() ? serverId : null,
year: options.worldState.currentYear,
month: options.worldState.currentMonth,
nationId: null,
@@ -18,7 +18,12 @@ const cityIds = [991_201, 991_202, 991_203, 991_204, 991_205, 991_206, 991_207];
const nationId = 991_201;
const yearbookProfile = 'monthly-boundary-pre-persistence';
const yearbookServerId = 'monthly-boundary-generation-20260731';
const archivedLogTexts = ['월경계 과거 정세', '월경계 과거 장수 동향', '월경계 과거 호환 행동'];
const archivedLogTexts = [
'월경계 과거 정세',
'월경계 과거 장수 동향',
'월경계 과거 호환 행동',
'월경계 감사 기수 로그',
];
integration('monthly pre-update persistence', () => {
let db: GamePrismaClient;
@@ -197,6 +202,12 @@ integration('monthly pre-update persistence', () => {
const hooks = await createDatabaseTurnHooks(databaseUrl!, world, { profileName: yearbookProfile });
try {
await world.advanceMonth(new Date('0201-01-01T00:00:00.000Z'));
world.pushLog({
scope: LogScope.GENERAL,
category: LogCategory.ACTION,
generalId: generalIds[0],
text: archivedLogTexts[3]!,
});
await hooks.hooks.flushChanges?.({
lastTurnTime: '0201-01-01T00:00:00.000Z',
processedGenerals: 0,
@@ -205,6 +216,12 @@ integration('monthly pre-update persistence', () => {
partial: false,
});
expect(await db.logEntry.findFirst({ where: { text: archivedLogTexts[3] } })).toMatchObject({
serverId: yearbookServerId,
});
expect(await db.logEntry.findFirst({ where: { text: archivedLogTexts[0] } })).toMatchObject({
serverId: null,
});
expect(
await db.generalAccessLog.findMany({
where: { generalId: { in: generalIds } },
@@ -214,7 +214,7 @@ integration('monthly nation betting persistence', () => {
currentMonth: 12,
tickSeconds: 600,
config: {},
meta: { lastBettingId: bettingId - 1 },
meta: { lastBettingId: bettingId - 1, serverId: 'audit-betting-fixture' },
},
});
const state: TurnWorldState = {
@@ -223,7 +223,7 @@ integration('monthly nation betting persistence', () => {
currentMonth: 12,
tickSeconds: 600,
lastTurnTime: new Date('2026-07-25T00:00:00.000Z'),
meta: { lastBettingId: bettingId - 1 },
meta: { lastBettingId: bettingId - 1, serverId: 'audit-betting-fixture' },
};
const scenarioConfig: TurnWorldSnapshot['scenarioConfig'] = {
stat: { total: 300, min: 10, max: 100, npcTotal: 150, npcMax: 75, npcMin: 10, chiefMin: 70 },
@@ -356,6 +356,7 @@ integration('monthly nation betting persistence', () => {
where: { text: { contains: '천통국 예상 내기의 결과' } },
})
).toMatchObject({
serverId: 'audit-betting-fixture',
year: 200,
month: 2,
text: '<C>●</>200년 2월:<B><b>【내기】</b></> 200년 1월에 열렸던 천통국 예상 내기의 결과가 나왔습니다!',