feat: 内容数据迁移至数据库,合规审查全链路打通
- 文章 HTML 存储从文件系统迁移至 articles 表,删除 releases 目录 - 合规审查从 DB 读取 HTML,审查结果写回 DB,通过后自动推进至待发布 - 新增 todayCount 筛选按钮,与系统概览统计数据一致 - 全屏预览修复:提升 z-index 超过侧边栏,添加退出全屏/关闭按钮 - 统一 '优化' → '审查' 命名,消除前后端术语不一致 - 调度器创作完成后自动触发审查(生成 → 审查 → 待发布) - 清理旧备份/调试文件、过期大纲和研究笔记
This commit is contained in:
+9
-53
@@ -1,68 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
重置指定选题状态为「待处理」(数据库 + JSON 备份)
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
PROJECT_ROOT = Path(__file__).parent.parent
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
try:
|
||||
from db_helper import update_topic_status, get_topic_by_id
|
||||
HAVE_DB = True
|
||||
except ImportError:
|
||||
HAVE_DB = False
|
||||
print("Warning: db_helper not available, will only update JSON")
|
||||
|
||||
DATA_DIR = PROJECT_ROOT / "automation" / "data"
|
||||
TOPICS_FILE = DATA_DIR / "sustainability_topics.json"
|
||||
|
||||
def reset_json_status(ids):
|
||||
try:
|
||||
with open(TOPICS_FILE, 'r', encoding='utf-8') as f:
|
||||
topics = json.load(f)
|
||||
except:
|
||||
topics = []
|
||||
updated_ids = []
|
||||
for t in topics:
|
||||
if t['id'] in ids:
|
||||
t['status'] = 'pending'
|
||||
if 'ready_at' in t:
|
||||
del t['ready_at']
|
||||
updated_ids.append(t['id'])
|
||||
with open(TOPICS_FILE, 'w', encoding='utf-8') as f:
|
||||
json.dump(topics, f, ensure_ascii=False, indent=2)
|
||||
return updated_ids
|
||||
|
||||
def reset_db_status(ids):
|
||||
if not HAVE_DB:
|
||||
return []
|
||||
updated = []
|
||||
for tid in ids:
|
||||
if update_topic_status(tid, 'pending'):
|
||||
updated.append(tid)
|
||||
return updated
|
||||
from db_helper import update_topic_status, get_topic_by_id
|
||||
|
||||
def main():
|
||||
# 指定要重置的ID列表
|
||||
target_ids = ['D01', 'B05'] # 可修改
|
||||
target_ids = ['D01', 'B05']
|
||||
print(f"正在重置选题状态: {target_ids}")
|
||||
|
||||
# 更新数据库
|
||||
db_updated = reset_db_status(target_ids) if HAVE_DB else []
|
||||
if db_updated:
|
||||
print(f"[DB] 已重置: {db_updated}")
|
||||
updated = []
|
||||
for tid in target_ids:
|
||||
if update_topic_status(tid, 'pending'):
|
||||
updated.append(tid)
|
||||
if updated:
|
||||
print(f"[DB] 已重置: {updated}")
|
||||
else:
|
||||
print("[DB] 未更新或数据库不可用")
|
||||
|
||||
# 更新 JSON 备份
|
||||
json_updated = reset_json_status(target_ids)
|
||||
print(f"[JSON] 已重置: {json_updated}")
|
||||
|
||||
print("[DB] 无更新")
|
||||
print("完成")
|
||||
|
||||
if __name__ == "__main__":
|
||||
import json
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user