feat: 内容数据迁移至数据库,合规审查全链路打通
- 文章 HTML 存储从文件系统迁移至 articles 表,删除 releases 目录 - 合规审查从 DB 读取 HTML,审查结果写回 DB,通过后自动推进至待发布 - 新增 todayCount 筛选按钮,与系统概览统计数据一致 - 全屏预览修复:提升 z-index 超过侧边栏,添加退出全屏/关闭按钮 - 统一 '优化' → '审查' 命名,消除前后端术语不一致 - 调度器创作完成后自动触发审查(生成 → 审查 → 待发布) - 清理旧备份/调试文件、过期大纲和研究笔记
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
遍历指定日期所有发布版本,执行合规检查,生成汇总报告
|
||||
"""
|
||||
|
||||
import json, re, datetime
|
||||
import re, datetime
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
@@ -12,29 +12,11 @@ PROJECT_ROOT = Path(__file__).parent.parent
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
from scripts.compliance_checker import check_article
|
||||
|
||||
# 尝试导入数据库
|
||||
try:
|
||||
from db_helper import export_topics_to_json
|
||||
HAVE_DB = True
|
||||
except ImportError:
|
||||
HAVE_DB = False
|
||||
from db_helper import get_topic_by_id
|
||||
|
||||
# 配置
|
||||
RELEASE_DIR = PROJECT_ROOT / "automation" / "data" / "releases"
|
||||
TODAY = datetime.date.today().isoformat() # 默认今天,可修改
|
||||
|
||||
def load_topics_from_db():
|
||||
if not HAVE_DB:
|
||||
raise RuntimeError("Database not available")
|
||||
topics = export_topics_to_json()
|
||||
return {t['id']: t for t in topics}
|
||||
|
||||
def load_topics_from_json():
|
||||
json_path = PROJECT_ROOT / "automation" / "data" / "sustainability_topics.json"
|
||||
with open(json_path, 'r', encoding='utf-8') as f:
|
||||
topics = json.load(f)
|
||||
return {t['id']: t for t in topics}
|
||||
TODAY = datetime.date.today().isoformat()
|
||||
|
||||
def extract_topic_id(filename: Path) -> str:
|
||||
stem = filename.stem
|
||||
@@ -48,14 +30,6 @@ def main(target_date: str = None):
|
||||
target_date = TODAY
|
||||
print(f"批量合规审查: {target_date}")
|
||||
|
||||
# 加载选题数据(优先DB,失败则备援JSON)
|
||||
try:
|
||||
topics_by_id = load_topics_from_db()
|
||||
print("[数据源] 数据库")
|
||||
except Exception as e:
|
||||
print(f"[数据源] 数据库失败: {e}, 改用 JSON")
|
||||
topics_by_id = load_topics_from_json()
|
||||
|
||||
release_path = RELEASE_DIR / target_date
|
||||
if not release_path.exists():
|
||||
print(f"错误:发布日期目录不存在 {release_path}")
|
||||
@@ -68,7 +42,7 @@ def main(target_date: str = None):
|
||||
for html_file in html_files:
|
||||
platform = html_file.parent.name
|
||||
topic_id = extract_topic_id(html_file)
|
||||
topic_data = topics_by_id.get(topic_id) if topic_id else None
|
||||
topic_data = get_topic_by_id(topic_id) if topic_id else None
|
||||
|
||||
with open(html_file, 'r', encoding='utf-8') as f:
|
||||
html_content = f.read()
|
||||
@@ -80,7 +54,6 @@ def main(target_date: str = None):
|
||||
result['topic_title'] = topic_data.get('title') if topic_data else "未知"
|
||||
results.append(result)
|
||||
|
||||
# 输出摘要
|
||||
passed = sum(1 for r in results if r['passed'])
|
||||
failed = len(results) - passed
|
||||
print(f"\n✅ 通过: {passed}, ⚠️ 需人工: {failed}")
|
||||
|
||||
Reference in New Issue
Block a user