feat(performance): 자동 업데이트 일정 설정 — 매출·광고비 따로 간격·요일·시작/끝
- 실적 설정 "자동 업데이트" 카드(관리자): 매출 실적·광고비 각각 사용·요일([매일]·[평일])· 시작/끝 시각(5분 단위)·간격(5~720분, 5분 단위, 기본 30분), PUT /api/auto-sync-schedule - 마이그레이션 011 perf_settings(key auto_sync, JSONB). 미적용·값 없음 = 기본 일정(매일 9~19시 30분) - auto_sync: 종류별 일정·Scheduler(1분마다 다시 읽어 바뀐 종류만 다시 계산, 종류마다 따로 스레드) - 매출·광고비 탭 카운트다운이 각자 일정대로 다음 회차 계산(nextScheduleSlot) - 테스트: 일정 계산·검증·Scheduler·저장 API·브라우저(설정 카드·카운트다운) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,10 @@ class MemoMigrationNeeded(Exception):
|
||||
"""날짜 칸 메모(마이그레이션 010: perf_cell_memos)가 아직 적용되지 않음."""
|
||||
|
||||
|
||||
class SettingsMigrationNeeded(Exception):
|
||||
"""설정 값 저장(마이그레이션 011: perf_settings — 자동 업데이트 일정)이 아직 적용되지 않음."""
|
||||
|
||||
|
||||
class ManualMigrationNeeded(Exception):
|
||||
"""수동 입력(마이그레이션 002: perf_marketplaces.manual_input · perf_manual_sales)이 아직 적용되지 않음."""
|
||||
|
||||
@@ -513,6 +517,28 @@ class PerformanceDBStore:
|
||||
except pg_errors.UndefinedTable:
|
||||
raise MemoMigrationNeeded() from None
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 설정 값(마이그레이션 011) — 키 하나 = JSONB. 'auto_sync' = 자동 업데이트 일정(auto_sync.py)
|
||||
# ════════════════════════════════════════════════════════════
|
||||
def get_setting(self, key: str) -> Any:
|
||||
"""값(없으면 None). 011 미적용이면 SettingsMigrationNeeded."""
|
||||
try:
|
||||
with self._pool.connection() as conn:
|
||||
row = conn.execute("SELECT value FROM perf_settings WHERE key = %s", (key,)).fetchone()
|
||||
except pg_errors.UndefinedTable:
|
||||
raise SettingsMigrationNeeded() from None
|
||||
return row["value"] if row else None
|
||||
|
||||
def set_setting(self, key: str, value: Any, *, user: str = "") -> None:
|
||||
try:
|
||||
with self._pool.connection() as conn:
|
||||
conn.execute(
|
||||
"INSERT INTO perf_settings (key, value, updated_by) VALUES (%s, %s, %s) "
|
||||
"ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_by = EXCLUDED.updated_by, "
|
||||
"updated_at = now()", (key, Jsonb(value), user))
|
||||
except pg_errors.UndefinedTable:
|
||||
raise SettingsMigrationNeeded() from None
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 광고비(마이그레이션 005)
|
||||
# ════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user