feat: 内容数据迁移至数据库,合规审查全链路打通
- 文章 HTML 存储从文件系统迁移至 articles 表,删除 releases 目录 - 合规审查从 DB 读取 HTML,审查结果写回 DB,通过后自动推进至待发布 - 新增 todayCount 筛选按钮,与系统概览统计数据一致 - 全屏预览修复:提升 z-index 超过侧边栏,添加退出全屏/关闭按钮 - 统一 '优化' → '审查' 命名,消除前后端术语不一致 - 调度器创作完成后自动触发审查(生成 → 审查 → 待发布) - 清理旧备份/调试文件、过期大纲和研究笔记
This commit is contained in:
+12
-9
@@ -14,7 +14,6 @@ sys.path.insert(0, str(PROJECT_ROOT))
|
||||
from db_helper import get_topic_by_id, get_next_topic, update_topic_status
|
||||
|
||||
DATA_DIR = PROJECT_ROOT / "automation" / "data"
|
||||
TOPICS_FILE = DATA_DIR / "sustainability_topics.json" # 保留用于备份
|
||||
LOGS_DIR = PROJECT_ROOT / "automation" / "logs"
|
||||
TODAY = datetime.datetime.now().strftime("%Y-%m-%d")
|
||||
|
||||
@@ -29,26 +28,30 @@ logging.basicConfig(
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def select_next_topic(topic_id: str = None) -> Dict:
|
||||
"""选择并锁定要创作的选题(从数据库)"""
|
||||
"""选择并锁定要创作的选题(趋势引擎匹配 → 回退优先级)"""
|
||||
if topic_id:
|
||||
# 指定ID,查询数据库
|
||||
topic = get_topic_by_id(topic_id)
|
||||
if not topic:
|
||||
raise ValueError(f"Topic {topic_id} not found")
|
||||
# 检查状态:禁止已发布状态重新创作
|
||||
current_status = topic.get('status')
|
||||
if current_status in ['已发布', 'published']:
|
||||
raise ValueError(f"Topic {topic_id} is already published, cannot recreate")
|
||||
# 更新状态为「审查中」表示已经开始处理
|
||||
update_topic_status(topic_id, 'review')
|
||||
return topic
|
||||
|
||||
# 自动选择:下一个待处理的选题
|
||||
|
||||
try:
|
||||
from topic_selector import select_best_topic as engine_select
|
||||
topic = engine_select()
|
||||
if topic:
|
||||
logger.info(f"选题引擎推荐: {topic['id']} {topic['title']}")
|
||||
update_topic_status(topic['id'], 'review')
|
||||
return topic
|
||||
except Exception as e:
|
||||
logger.warning(f"选题引擎失效,回退简单策略: {e}")
|
||||
|
||||
topic = get_next_topic(priority='高') or get_next_topic()
|
||||
if not topic:
|
||||
raise ValueError("No available topics to create (all locked or wrong status)")
|
||||
|
||||
# 更新状态为「审查中」表示已锁定
|
||||
update_topic_status(topic['id'], 'review')
|
||||
return topic
|
||||
|
||||
|
||||
Reference in New Issue
Block a user