feat(performance): 날짜 칸 메모·광고비 표 열 너비 자동/날짜 열 고정·기타광고비 열
- 매출 실적·광고비 금액 입력 칸 우클릭 → 메모 삽입·수정·삭제(창), 메모 있는 칸 빨간 삼각형·마우스 올리면 메모 상자
(마이그레이션 010 perf_cell_memos, PUT /api/cell-memos/{kind}/{code}/{date})
- 광고비 표도 열 너비 = 내용 길이, 날짜 열 가로 스크롤 고정(perf-autofit)
- 기타광고비 열(etc, 애터미아자몰 오른쪽) — ROAS 없음
- 테스트: test_cell_memos.py, perf_memo_ads.browser.test.js, 기존 채널 목록 기대값
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,10 @@ from app.timezone import to_kst_iso
|
||||
STALE_RUN_AFTER = timedelta(minutes=30)
|
||||
|
||||
|
||||
class MemoMigrationNeeded(Exception):
|
||||
"""날짜 칸 메모(마이그레이션 010: perf_cell_memos)가 아직 적용되지 않음."""
|
||||
|
||||
|
||||
class ManualMigrationNeeded(Exception):
|
||||
"""수동 입력(마이그레이션 002: perf_marketplaces.manual_input · perf_manual_sales)이 아직 적용되지 않음."""
|
||||
|
||||
@@ -481,6 +485,34 @@ class PerformanceDBStore:
|
||||
return {}
|
||||
return {(r["sales_date"], r["marketplace_code"]): r["formula"] for r in rows}
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 날짜 칸 메모(마이그레이션 010) — kind 'sales'(쇼핑몰)·'ad'(광고 채널). 금액과 따로(금액을 지워도 남음).
|
||||
# ════════════════════════════════════════════════════════════
|
||||
def cell_memos(self, kind: str, start: date, end: date) -> dict[tuple[date, str], str]:
|
||||
"""(날짜, 코드) → 메모. 010 미적용이면 비어 있음."""
|
||||
try:
|
||||
with self._pool.connection() as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT memo_date, code, memo FROM perf_cell_memos WHERE kind = %s AND memo_date BETWEEN %s AND %s",
|
||||
(kind, start, end)).fetchall()
|
||||
except pg_errors.UndefinedTable:
|
||||
return {}
|
||||
return {(r["memo_date"], r["code"]): r["memo"] for r in rows}
|
||||
|
||||
def set_cell_memo(self, kind: str, code: str, day: date, memo: str | None, *, user: str = "") -> None:
|
||||
"""메모 저장(빈 값·None = 지움). 010 미적용이면 MemoMigrationNeeded."""
|
||||
try:
|
||||
with self._pool.connection() as conn:
|
||||
if not memo:
|
||||
conn.execute("DELETE FROM perf_cell_memos WHERE kind = %s AND code = %s AND memo_date = %s", (kind, code, day))
|
||||
else:
|
||||
conn.execute(
|
||||
"INSERT INTO perf_cell_memos (kind, code, memo_date, memo, updated_by) VALUES (%s, %s, %s, %s, %s) "
|
||||
"ON CONFLICT (kind, code, memo_date) DO UPDATE SET memo = EXCLUDED.memo, updated_by = EXCLUDED.updated_by, "
|
||||
"updated_at = now()", (kind, code, day, memo, user))
|
||||
except pg_errors.UndefinedTable:
|
||||
raise MemoMigrationNeeded() from None
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 광고비(마이그레이션 005)
|
||||
# ════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user