233e23016c
- 文章 HTML 存储从文件系统迁移至 articles 表,删除 releases 目录 - 合规审查从 DB 读取 HTML,审查结果写回 DB,通过后自动推进至待发布 - 新增 todayCount 筛选按钮,与系统概览统计数据一致 - 全屏预览修复:提升 z-index 超过侧边栏,添加退出全屏/关闭按钮 - 统一 '优化' → '审查' 命名,消除前后端术语不一致 - 调度器创作完成后自动触发审查(生成 → 审查 → 待发布) - 清理旧备份/调试文件、过期大纲和研究笔记
70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
批量合规审查脚本 - 数据库版
|
|
遍历指定日期所有发布版本,执行合规检查,生成汇总报告
|
|
"""
|
|
|
|
import re, datetime
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
PROJECT_ROOT = Path(__file__).parent.parent
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
from scripts.compliance_checker import check_article
|
|
from db_helper import get_topic_by_id
|
|
|
|
# 配置
|
|
RELEASE_DIR = PROJECT_ROOT / "automation" / "data" / "releases"
|
|
TODAY = datetime.date.today().isoformat()
|
|
|
|
def extract_topic_id(filename: Path) -> str:
|
|
stem = filename.stem
|
|
parts = stem.split('_')
|
|
if len(parts) >= 2:
|
|
return parts[1]
|
|
return None
|
|
|
|
def main(target_date: str = None):
|
|
if target_date is None:
|
|
target_date = TODAY
|
|
print(f"批量合规审查: {target_date}")
|
|
|
|
release_path = RELEASE_DIR / target_date
|
|
if not release_path.exists():
|
|
print(f"错误:发布日期目录不存在 {release_path}")
|
|
return
|
|
|
|
html_files = list(release_path.rglob("*.html"))
|
|
print(f"找到 {len(html_files)} 个HTML文件,开始合规审查...\n")
|
|
|
|
results = []
|
|
for html_file in html_files:
|
|
platform = html_file.parent.name
|
|
topic_id = extract_topic_id(html_file)
|
|
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()
|
|
|
|
result = check_article(html_content, platform, topic_data)
|
|
result['file'] = str(html_file.relative_to(PROJECT_ROOT))
|
|
result['platform'] = platform
|
|
result['topic_id'] = topic_id
|
|
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}")
|
|
for r in results:
|
|
status = "✅" if r['passed'] else "⚠️"
|
|
print(f" {status} {r['topic_id']} {r['topic_title'][:40]}...")
|
|
|
|
if __name__ == "__main__":
|
|
import argparse
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--date', help='审查的日期目录,默认今天')
|
|
args = parser.parse_args()
|
|
main(args.date)
|