feat(pchome): close freshness and multi-market decision gaps
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
ogt
2026-07-10 21:22:42 +08:00
parent 744cd946f3
commit b8cc27e4c4
29 changed files with 1373 additions and 123 deletions

View File

@@ -94,7 +94,10 @@ def _safe_driver_title(driver, task_label, url):
def _save_stats(task_name, data):
"""將任務統計結果寫入 JSON 檔案"""
stats_file = os.path.join(os.path.dirname(__file__), 'data', 'scheduler_stats.json')
stats_file = os.getenv(
'SCHEDULER_STATS_PATH',
os.path.join(os.path.dirname(__file__), 'data', 'scheduler_stats.json'),
)
try:
stats = {}
if os.path.exists(stats_file):
@@ -2043,7 +2046,12 @@ def run_auto_import_task():
stats = {
"file_count": result.get('file_count', 0),
"imported_count": result.get('imported_count', 0),
"status": "Success"
"status": "Degraded" if result.get('status') in {'upstream_stale', 'upstream_missing'} else "Success",
"upstream_status": result.get('status'),
"latest_sales_date": result.get('latest_sales_date'),
"data_lag_days": result.get('data_lag_days'),
"decision_ready": result.get('decision_ready'),
"requires_upstream_acquisition": result.get('requires_upstream_acquisition', False),
}
# V-New: 發送 Telegram 和 Line 通知(僅當有匯入新檔案時)