From 41310dbe6adfb30289c79c393f975387083f2f51 Mon Sep 17 00:00:00 2001 From: altair823 Date: Sun, 10 May 2026 14:06:28 +0900 Subject: [PATCH] =?UTF-8?q?refactor(v032):=20KST=5FOFFSET=5FMS=20inline=20?= =?UTF-8?q?=E2=86=92=20@shared/util/kstDate=20import=20(#19)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5 callsite (NoteRepository, ftsHelpers, BackupService, ContinuityService, NoteCard) 모두 canonical export 로 정리. 알고리즘 동일 (9 * 60 * 60 * 1000), 회귀 PASS 검증. v0.2.6 commit 3cfa60b 가 4 callsite migrate 했지만 5 callsite 잔여. Cut F audit 에서 발견. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/main/repository/NoteRepository.ts | 3 +-- src/main/repository/ftsHelpers.ts | 4 ++-- src/main/services/BackupService.ts | 3 +-- src/main/services/ContinuityService.ts | 3 +-- src/renderer/inbox/components/NoteCard.tsx | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/repository/NoteRepository.ts b/src/main/repository/NoteRepository.ts index e74cbd1..5d73883 100644 --- a/src/main/repository/NoteRepository.ts +++ b/src/main/repository/NoteRepository.ts @@ -1,7 +1,7 @@ import type Database from 'better-sqlite3'; import { v7 as uuidv7, v4 as uuidv4 } from 'uuid'; import type { AiStatus, Note, NoteMedia, NoteRevision, NoteStatus, NoteTag } from '@shared/types'; -import { kstTodayIso } from '../../shared/util/kstDate.js'; +import { kstTodayIso, KST_OFFSET_MS } from '../../shared/util/kstDate.js'; import { sanitizeFtsQuery, computeCutoff, type ReviewPeriod } from './ftsHelpers.js'; export interface CreateNoteInput { @@ -1039,7 +1039,6 @@ export class NoteRepository { * and count rows whose UTC ISO `created_at` lies inside. */ countToday(now: Date = new Date()): number { - const KST_OFFSET_MS = 9 * 60 * 60 * 1000; const kstNow = new Date(now.getTime() + KST_OFFSET_MS); const kstYear = kstNow.getUTCFullYear(); const kstMonth = kstNow.getUTCMonth(); diff --git a/src/main/repository/ftsHelpers.ts b/src/main/repository/ftsHelpers.ts index 47ccac0..f81ac5d 100644 --- a/src/main/repository/ftsHelpers.ts +++ b/src/main/repository/ftsHelpers.ts @@ -2,6 +2,8 @@ * v0.2.11 Cut D — FTS5 검색 + 회고 view 의 순수 함수 헬퍼. */ +import { KST_OFFSET_MS } from '../../shared/util/kstDate.js'; + const FTS5_SPECIAL_CHARS_RE = /["*():]/g; const WS_COLLAPSE_RE = /\s+/g; @@ -15,8 +17,6 @@ export function sanitizeFtsQuery(input: string): string { export type ReviewPeriod = 'daily' | 'weekly' | 'monthly'; -const KST_OFFSET_MS = 9 * 60 * 60 * 1000; - /** * 회고 cutoff = period 시작점의 KST 자정 (UTC ISO). * daily = 오늘 0시, weekly = 7일 전 0시, monthly = 30일 전 0시. diff --git a/src/main/services/BackupService.ts b/src/main/services/BackupService.ts index 6e60a0b..cb0a7c7 100644 --- a/src/main/services/BackupService.ts +++ b/src/main/services/BackupService.ts @@ -2,8 +2,7 @@ import type Database from 'better-sqlite3'; import { mkdir, rename, stat, readdir, unlink, readFile, writeFile } from 'node:fs/promises'; import { join } from 'node:path'; import { applyGfsRetention } from './backupRotation.js'; - -const KST_OFFSET_MS = 9 * 60 * 60 * 1000; +import { KST_OFFSET_MS } from '../../shared/util/kstDate.js'; const MARKER_FILENAME = '.last-snapshot'; function toKstDateKey(d: Date): string { diff --git a/src/main/services/ContinuityService.ts b/src/main/services/ContinuityService.ts index 54e4263..9d0a4ec 100644 --- a/src/main/services/ContinuityService.ts +++ b/src/main/services/ContinuityService.ts @@ -1,7 +1,6 @@ import type Database from 'better-sqlite3'; import type { WeeklyContinuity } from '@shared/types'; - -const KST_OFFSET_MS = 9 * 60 * 60 * 1000; +import { KST_OFFSET_MS } from '../../shared/util/kstDate.js'; const ONE_DAY_MS = 24 * 60 * 60 * 1000; const WEEK_TARGET = 7; const RECOVERY_GAP_DAYS = 7; diff --git a/src/renderer/inbox/components/NoteCard.tsx b/src/renderer/inbox/components/NoteCard.tsx index 763d812..64e8d49 100644 --- a/src/renderer/inbox/components/NoteCard.tsx +++ b/src/renderer/inbox/components/NoteCard.tsx @@ -1,5 +1,6 @@ import React, { useState } from 'react'; import type { Note, NoteStatus } from '@shared/types'; +import { KST_OFFSET_MS } from '@shared/util/kstDate.js'; import { inboxApi } from '../api.js'; import { useInbox } from '../store.js'; import { EditableField } from './EditableField.js'; @@ -27,7 +28,6 @@ function isPastDue(iso: string, today: string): boolean { } function todayKstIso(): string { - const KST_OFFSET_MS = 9 * 60 * 60 * 1000; const k = new Date(Date.now() + KST_OFFSET_MS); return k.toISOString().slice(0, 10); }