Commit Graph

8 Commits

Author SHA1 Message Date
OoO
eb9cac0d19 改善活動看板手機導覽排版
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
2026-05-12 23:50:18 +08:00
OoO
75de76ac12 fix(momo): block EC404 auto-open with end-to-end URL guard
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
- normalize URLs at write time (scheduler crawlers, routes) to drop
  javascript:/EC404/placeholder i_code (momo_/manual_/pchome_)
- add global click+auxclick guard in base.html and ewoooc_base.html
  that intercepts blocked MOMO URLs and redirects to safe i_code URL
- per-page dashboards reuse the same isLikelyMomoIcode validation
- /api/track_momo_link records blocked events for diagnosis
- ship sanitize_momo_urls.py to clean existing polluted DB rows

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 12:00:34 +08:00
ooo
17cb012be7 refactor(p1-01c): 整併 utils/security 與 utils/validators 重複實作
All checks were successful
CD Pipeline / deploy (push) Successful in 1m6s
發現 utils/validators.py 已存在且完整重複 utils/security.py 的 9 個函數。
不收拾的話會繼續腐爛 — 立刻整併為單一權威來源。

變更:
- utils/security.py 增加 safe_read_sql(取自 validators.py 較完整版本,含 limit + params)
- utils/security.py ALLOWED_TABLES 取兩份聯集(補上 monthly_summary_analysis,
  realtime_sales_daily),避免破壞既有呼叫者
- utils/validators.py 改為純 re-export shim(保 from utils.validators import 不破)
- app.py 移除原 safe_read_sql 重複定義(35 行),改 import utils.security

routes/import_routes.py 不變(它 from utils.validators 走得到 re-export,等下輪統一)。

行數變化: app.py 7,187 → 7,151 (-36)
2026-04-28 15:48:41 +08:00
ooo
0a3f6cb22d refactor(p1-01b): app.py 文字/顏色/數字工具抽到 utils/text_helpers.py
All checks were successful
CD Pipeline / deploy (push) Successful in 1m7s
- slugify, get_color_for_string, extract_snapshot_date_from_filename, number_format
- @app.template_filter('number_format') 保留為 Jinja 註冊薄殼,實作走 utils
- app.py: 7,206 → 7,187 (-19)
2026-04-28 15:44:15 +08:00
ooo
f7a5f8505f refactor(p1-01a): app.py 安全工具抽到 utils/security.py
All checks were successful
CD Pipeline / deploy (push) Successful in 1m8s
從 app.py 抽出純驗證邏輯 (~180 行) 到 utils/security.py:
- ALLOWED_TABLES 白名單常數
- validate_table_name / validate_column_names (SQL injection 防護)
- safe_join (路徑遍歷防護)
- ALLOWED_UPLOAD_EXTENSIONS / ALLOWED_MIME_TYPES
- secure_filename_unicode / allowed_file / validate_upload_file (上傳驗證)

app.py 保留 from utils.security import * 維持 backward compat,
讓 tests/test_path_traversal.py、tests/test_sql_security.py、
tests/test_file_upload.py 不需修改即可繼續使用 from app import xxx。

行數變化: app.py 7,386 → 7,206 (-180)
2026-04-28 15:42:44 +08:00
ooo
d4ea555030 refactor(p1-06/07): daily_sales 純函數抽到 services/
All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
- 新增 utils/df_helpers.py 放共用 find_col(避免 routes/services 雙向依賴)
- 新增 services/daily_sales_service.py 收:
  * get_taiwan_holiday(date)
  * prepare_calendar_data(df, selected_month)
  * prepare_marketing_summary(df, ...)
- routes/daily_sales_routes.py 改為 import service,行數 949 → 713(-236)
- 行為 100% 保留,僅檔案位置搬移
2026-04-28 15:37:07 +08:00
ogt
4a648ea6bf refactor: fix reverse dependencies — logger_manager→utils, dashboard_service extraction
- Move SystemLogger implementation to utils/logger_manager.py (pure utility, no deps)
- services/logger_manager.py becomes a backward-compat re-export shim
- database/manager.py and database/vendor_manager.py now import from utils layer
- Extract get_dashboard_stats() to services/dashboard_service.py
- services/task_runner.py no longer imports from routes layer
- routes/dashboard_routes.py get_dashboard_stats() delegates to service layer

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 21:28:23 +08:00
ogt
1b4f3a7bbe feat: EwoooC 初始化 — 完整專案推版至 Gitea
Some checks failed
CD Pipeline / deploy (push) Failing after 59s
- 建立 Gitea Actions CD pipeline (.gitea/workflows/cd.yaml)
- 部署模式: rsync Python 檔案至 188 → docker restart (volume mount)
- Dockerfile/requirements 變動時自動重建 Docker image
- 部署通知: Telegram (開始/成功/失敗)
- 健康檢查: https://mo.wooo.work/health (最多 5 次重試)
- 同步最新 CLAUDE.md / ADR-008 / memory (2026-04-19)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 01:21:13 +08:00