feat: implement monthly city supply update
This commit is contained in:
@@ -19,15 +19,17 @@ export const finalizeLogEntry = (entry: LogEntryDraft, context: LogContext): Log
|
||||
return null;
|
||||
}
|
||||
|
||||
const year = entry.year ?? context.year;
|
||||
const month = entry.month ?? context.month;
|
||||
const format = entry.format ?? LogFormat.RAWTEXT;
|
||||
const text = formatLogText(entry.text, format, context.year, context.month);
|
||||
const text = formatLogText(entry.text, format, year, month);
|
||||
|
||||
const record: LogEntryRecord = {
|
||||
scope: entry.scope,
|
||||
category: entry.category,
|
||||
text,
|
||||
year: context.year,
|
||||
month: context.month,
|
||||
year,
|
||||
month,
|
||||
};
|
||||
|
||||
if (entry.generalId !== undefined) {
|
||||
|
||||
@@ -28,6 +28,9 @@ export interface LogEntryDraft {
|
||||
subType?: string;
|
||||
meta?: Record<string, unknown>;
|
||||
format?: LogFormat;
|
||||
/** 월 경계 전 action처럼 flush 시점과 다른 달에 귀속되는 로그의 명시적 날짜. */
|
||||
year?: number;
|
||||
month?: number;
|
||||
}
|
||||
|
||||
export interface LogEntryRecord {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { finalizeLogEntry, LogCategory, LogFormat, LogScope } from '../src/index.js';
|
||||
|
||||
describe('finalizeLogEntry', () => {
|
||||
it('uses an explicit draft year and month for pre-month logs', () => {
|
||||
expect(
|
||||
finalizeLogEntry(
|
||||
{
|
||||
scope: LogScope.SYSTEM,
|
||||
category: LogCategory.HISTORY,
|
||||
text: '이전 달 사건',
|
||||
format: LogFormat.YEAR_MONTH,
|
||||
year: 193,
|
||||
month: 12,
|
||||
},
|
||||
{ year: 194, month: 1 }
|
||||
)
|
||||
).toMatchObject({
|
||||
year: 193,
|
||||
month: 12,
|
||||
text: '<C>●</>193년 12월:이전 달 사건',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user