From 1e4adc63c0cea1d5b46cee854873b16ddbfc36df Mon Sep 17 00:00:00 2001 From: wuyanwanwu <104009119+wuyanwanwu@users.noreply.github.com.> Date: Mon, 10 Aug 2026 00:41:37 +0800 Subject: [PATCH] Fix ingestion conflicts and local report date --- db/migrations/004_n8n_ingestion.sql | 4 ++-- web/public/app.js | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/db/migrations/004_n8n_ingestion.sql b/db/migrations/004_n8n_ingestion.sql index 84b7920..dd5b894 100644 --- a/db/migrations/004_n8n_ingestion.sql +++ b/db/migrations/004_n8n_ingestion.sql @@ -105,7 +105,7 @@ BEGIN 'published', 'skipped' ) - ON CONFLICT (report_date) DO UPDATE SET + ON CONFLICT ON CONSTRAINT uq_daily_reports_report_date DO UPDATE SET title = EXCLUDED.title, introduction = EXCLUDED.introduction, status = 'published', @@ -123,7 +123,7 @@ BEGIN importance_score >= 85 FROM news_articles WHERE id = v_article_id - ON CONFLICT (report_id, article_id) DO UPDATE SET + ON CONFLICT ON CONSTRAINT report_articles_pkey DO UPDATE SET section = EXCLUDED.section, display_order = EXCLUDED.display_order, is_highlight = EXCLUDED.is_highlight; diff --git a/web/public/app.js b/web/public/app.js index 2495e56..7a15f75 100644 --- a/web/public/app.js +++ b/web/public/app.js @@ -2,7 +2,13 @@ const $ = (selector) => document.querySelector(selector); const escapeHtml = (value) => String(value ?? '').replace(/[&<>'"]/g, (char) => ({ '&': '&', '<': '<', '>': '>', "'": ''', '"': '"' }[char])); const categoryNames = { general: '综合', ai_agent: 'AI 与 Agent', agri_hardware: '农业硬件', agri_solutions: '方案落地', agri_services: '农业服务', policy_market: '政策市场' }; -function today() { return new Date().toISOString().slice(0, 10); } +function today() { + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, '0'); + const day = String(now.getDate()).padStart(2, '0'); + return `${year}-${month}-${day}`; +} function formatDate(value) { return value ? new Intl.DateTimeFormat('zh-CN', { year: 'numeric', month: 'long', day: 'numeric', weekday: 'short' }).format(new Date(`${value}T00:00:00`)) : '—'; } function formatTime(value) { return value ? new Intl.DateTimeFormat('zh-CN', { month: 'short', day: 'numeric' }).format(new Date(value)) : '近期'; }