fix: 개인 기록에 장수별 실행 시각을 보존
로그 발생 시각과 트랜잭션 flush 시각을 분리하고, 정규 및 즉시 장수 행동 로그에는 실행 전 장수 턴 시각을 기록한다. 기존 로그 행은 변경하지 않는다.
This commit is contained in:
@@ -47,8 +47,9 @@ export const finalizeLogEntry = (entry: LogEntryDraft, context: LogContext): Log
|
||||
if (entry.meta !== undefined) {
|
||||
record.meta = entry.meta;
|
||||
}
|
||||
if (context.at !== undefined) {
|
||||
record.createdAt = context.at;
|
||||
const createdAt = entry.occurredAt ?? context.at;
|
||||
if (createdAt !== undefined) {
|
||||
record.createdAt = createdAt;
|
||||
}
|
||||
|
||||
return record;
|
||||
|
||||
@@ -31,6 +31,8 @@ export interface LogEntryDraft {
|
||||
/** 월 경계 전 action처럼 flush 시점과 다른 달에 귀속되는 로그의 명시적 날짜. */
|
||||
year?: number;
|
||||
month?: number;
|
||||
/** 로그를 만든 논리 게임 시각. 생략하면 flush context의 시각을 사용한다. */
|
||||
occurredAt?: Date;
|
||||
}
|
||||
|
||||
export interface LogEntryRecord {
|
||||
|
||||
@@ -22,4 +22,22 @@ describe('finalizeLogEntry', () => {
|
||||
text: '<C>●</>193년 12월:이전 달 사건',
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps an explicit occurrence time instead of replacing it with the flush time', () => {
|
||||
const occurredAt = new Date('0200-01-01T00:37:43.000Z');
|
||||
const flushAt = new Date('0200-01-01T00:40:00.000Z');
|
||||
|
||||
expect(
|
||||
finalizeLogEntry(
|
||||
{
|
||||
scope: LogScope.GENERAL,
|
||||
category: LogCategory.ACTION,
|
||||
text: '상업 투자를 실행했습니다.',
|
||||
generalId: 1,
|
||||
occurredAt,
|
||||
},
|
||||
{ year: 200, month: 1, at: flushAt }
|
||||
)?.createdAt
|
||||
).toEqual(occurredAt);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user