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:
2026-10-26 18:01:00 +09:00
parent 5d30433019
commit 07861dfe8c
18 changed files with 936 additions and 96 deletions
+10 -1
View File
@@ -21,6 +21,7 @@ OUT_DIR = os.path.join(ROOT, "tests", "js", ".out")
from app.modules.performance.ad_spend import build_ad_dashboard # noqa: E402
from app.modules.performance.dashboard import amount_text, build_dashboard, build_settings # noqa: E402
from app.modules.performance.router import _auto_sync_settings_ctx # noqa: E402
BASE_STUB = ("{% block head_extra %}{% endblock %}<body><main class='erp-page'>{% block content %}{% endblock %}</main>"
"{% block scripts %}{% endblock %}</body>")
@@ -90,7 +91,10 @@ def main() -> None:
"unit": "won", "unit_label": "원", "amt": lambda v: amount_text(v)}
ctx = build_dashboard(FakeStore(), kind="week", anchor=date(2026, 10, 7), today=date(2026, 10, 7))
# 다음 자동 업데이트(router._auto_sync_ctx 와 같은 모양) — 화면이 초 단위로 센다
ctx["auto_sync"] = {"next_at": "2026-10-07T10:30:00+09:00", "now": "2026-10-07T10:17:25.000+09:00", "hours": [9, 19], "slot": 30}
# 일정 = 실적 설정 "자동 업데이트"(2026-10-26) — 화면이 schedule 로 다음 회차를 계산
ctx["auto_sync"] = {"next_at": "2026-10-07T10:30:00+09:00", "now": "2026-10-07T10:17:25.000+09:00",
"schedule": {"enabled": True, "interval": 30, "days": [0, 1, 2, 3, 4, 5, 6], "start": "09:00", "end": "19:00"},
"label": "매일 09:00~19:00 · 30분마다"}
html = e.get_template("performance/index.html").render(**base, active_tab="dashboard", metric="net", **ctx)
with open(os.path.join(OUT_DIR, "perf_dash.html"), "w", encoding="utf-8") as f:
f.write(html)
@@ -121,9 +125,14 @@ def main() -> None:
sctx["ad_sources"] = [{"code": "google", "name": "구글 광고", "configured": True, "status": "ok", "status_label": "정상 연결",
"last_test_at": "2026-10-15T10:00:00+09:00", "last_error": "", "last_error_at": None,
"last_sync_at": "2026-10-15T10:30:02+09:00", "last_success_sync_at": "2026-10-15T10:30:02+09:00"}]
# 자동 업데이트 일정 카드(2026-10-26) — 실제 router._auto_sync_settings_ctx(저장소에 get_setting 없음 → 기본 일정)
sctx["auto_sync_settings"] = _auto_sync_settings_ctx(FakeStore())
html = e.get_template("performance/settings.html").render(**base, active_tab="settings", **sctx)
with open(os.path.join(OUT_DIR, "perf_settings.html"), "w", encoding="utf-8") as f:
f.write(html)
html = shell.get_template("performance/settings.html").render(**sbase, active_tab="settings", **sctx)
with open(os.path.join(OUT_DIR, "perf_settings_shell.html"), "w", encoding="utf-8") as f:
f.write(html)
# 직접 추가 쇼핑몰·그룹(2026-10-22) — perf_dash_groups.html · perf_settings_groups.html (perf_groups.browser.test.js)
gctx = build_dashboard(GroupStore(), kind="week", anchor=date(2026, 10, 7), today=date(2026, 10, 7))
gctx["auto_sync"] = None