feat(실적): 틱톡 탭 삭제 + [말레이시아 실적] 모듈 추가

- 실적 틱톡 탭·tiktok_ads 광고 API·테스트 삭제, 틱톡 데이터 삭제 SQL(performance_db 012)
- 말레이시아 실적: 실적 라우터·화면을 /malaysia/performance 에 한 번 더 마운트,
  차이는 performance/variant.py(KR·MY) 한 곳 — 저장소·권한키·주소·광고 채널·통화
- 틱톡·쇼피·라자다 그룹(쇼핑몰 + 라이브커머스 하위, 그룹 열 = 합계), 광고비 채널 3개
- 금액 RM 소수 2자리 = 센 정수 저장(입력·엑셀 scale, 화면 num/money, JS money)
- malaysia_performance_db = performance_db 구조 복사 + seed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 16:03:18 +09:00
parent e9f57b6ff6
commit 62cc5e2778
34 changed files with 790 additions and 892 deletions
+23 -14
View File
@@ -19,9 +19,10 @@ ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)
sys.path.insert(0, ROOT)
OUT_DIR = os.path.join(ROOT, "tests", "js", ".out")
from app.modules.performance.ad_spend import build_ad_dashboard, build_tiktok_dashboard # noqa: E402
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
from app.modules.performance import variant # noqa: E402
BASE_STUB = ("{% block head_extra %}{% endblock %}<body><main class='erp-page'>{% block content %}{% endblock %}</main>"
"{% block scripts %}{% endblock %}</body>")
@@ -84,17 +85,11 @@ def env() -> jinja2.Environment:
return e
class TiktokStore:
def ad_details(self, code, start, end):
rows = [("2026-10-02", 120000, 480000), ("2026-10-05", 90000, 150000), ("2026-09-20", 50000, 100000)]
return [{"date": d, "amount": a, "roas": None, "metrics": {"매출": b}, "source": "api"} for d, a, b in rows]
def main() -> None:
os.makedirs(OUT_DIR, exist_ok=True)
e = env()
base = {"user": {"email": "me@test.local"}, "is_admin": True, "nav_items": [], "page_title": "실적", "page_subtitle": "",
"unit": "won", "unit_label": "원", "amt": lambda v: amount_text(v), "colw": "auto"}
"unit": "won", "unit_label": "원", "amt": lambda v: amount_text(v), "colw": "auto", **variant.template_ctx()}
ctx = build_dashboard(FakeStore(), kind="week", anchor=date(2026, 10, 7), today=date(2026, 10, 7))
# 다음 자동 업데이트(router._auto_sync_ctx 와 같은 모양) — 화면이 초 단위로 센다
# 일정 = 실적 설정 "자동 업데이트"(2026-10-26) — 화면이 schedule 로 다음 회차를 계산
@@ -123,12 +118,6 @@ def main() -> None:
html = shell.get_template("performance/ads.html").render(**sbase, active_tab="ads", **sactx)
with open(os.path.join(OUT_DIR, "perf_ads_shell.html"), "w", encoding="utf-8") as f:
f.write(html)
# 틱톡 탭(2026-11-05) — 가상의 광고 API 값
tk = build_tiktok_dashboard(TiktokStore(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7), holidays={"2026-10-03": "개천절"})
tk.update(auto_sync=ctx["auto_sync"], update_watch={"kind": "ads", "seen": "job-old"}, tiktok_configured=True, ad_running=False,
ad_last_update_at=None, ad_sync_sources=[{"code": "tiktok", "name": "틱톡"}])
with open(os.path.join(OUT_DIR, "perf_tiktok_shell.html"), "w", encoding="utf-8") as f:
f.write(shell.get_template("performance/tiktok.html").render(**sbase, active_tab="tiktok", **tk))
actx =build_ad_dashboard(FakeStore(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7),
sales_codes=["cafe24", "coupang"])
actx["ad_sync_sources"] = [{"code": "google", "name": "구글 광고"}] # [구글 광고 불러오기]
@@ -171,9 +160,29 @@ def main() -> None:
html = shell.get_template("performance/ads.html").render(**{**sbase, "colw": "manual"}, active_tab="ads", **sactx)
with open(os.path.join(OUT_DIR, "perf_ads_colw_shell.html"), "w", encoding="utf-8") as f:
f.write(html)
render_malaysia(e, base)
print("ok")
def render_malaysia(e: jinja2.Environment, base: dict) -> None:
"""말레이시아 실적(2026-11-20) — perf_my_dash.html · perf_my_ads.html (perf_malaysia.browser.test.js). 금액 = 센."""
from app.modules.performance.tests.test_malaysia_variant import _Store # noqa: WPS433
token = variant._current.set(variant.MY)
try:
mb = {**base, **variant.template_ctx(), "unit": "rm", "unit_label": "RM", "amt": lambda v: amount_text(v, "rm")}
ctx = build_dashboard(_Store(), kind="week", anchor=date(2026, 10, 7), today=date(2026, 10, 7))
ctx.update(auto_sync=None, update_watch=None)
with open(os.path.join(OUT_DIR, "perf_my_dash.html"), "w", encoding="utf-8") as f:
f.write(e.get_template("performance/index.html").render(**mb, active_tab="dashboard", metric="gross", **ctx))
actx = build_ad_dashboard(_Store(), kind="week", anchor=date(2026, 10, 7), today=date(2026, 10, 7), sales_codes=[])
actx.update(auto_sync=None, update_watch=None)
with open(os.path.join(OUT_DIR, "perf_my_ads.html"), "w", encoding="utf-8") as f:
f.write(e.get_template("performance/ads.html").render(**mb, active_tab="ads", **actx))
finally:
variant._current.reset(token)
class GroupStore(FakeStore):
"""카페24·네이버 + 그룹 '오프라인'(매장A·매장B) + 그룹 없는 직접 추가 '행사'."""