配置全面迁移数据库:PromptConfig、TaskConfig动态调度、敏感词/清洗规则/趋势映射/平台标签/痛点模板全部可编辑
- 新增 PromptConfig 模型 + API,支持提示词在线编辑(16条默认) - 调度器动态读取 TaskConfig.schedule,admin 可调执行时间 - 新增 KeywordDomainMap、SensitiveWord、ContentCleanRule、TrendFieldMapping 表 - DOMAINS、TREND_DOMAIN_MAP、PLATFORM_TAGS、china_pains、RSS关键词、priority_weights 全部迁移到 DB - tasks.html 重构:卡片网格+配置/产出/历史/提示词四个Tab,折叠显示 - 清理冗余代码:DEFAULT_PROMPTS死代码、collector.py unreachable代码、compliance_checker bug - strip_thinking_html 改用 DB 规则优先
This commit is contained in:
@@ -213,6 +213,25 @@ def get_module_detail(module_id: str, db: Session = Depends(get_db), current_use
|
||||
LOGS_DIR = ROOT / "automation" / "logs"
|
||||
today_str = date_mod.today().isoformat()
|
||||
|
||||
try:
|
||||
return _get_module_detail_data(module_id, db, ROOT, DATA_DIR, LOGS_DIR, today_str)
|
||||
except Exception as e:
|
||||
return {
|
||||
"module_id": module_id,
|
||||
"title": module_id,
|
||||
"description": "",
|
||||
"status": "stopped",
|
||||
"inputs": {},
|
||||
"outputs": {"error": str(e)},
|
||||
"history": [],
|
||||
"log_excerpt": "",
|
||||
}
|
||||
|
||||
def _get_module_detail_data(module_id: str, db, ROOT, DATA_DIR, LOGS_DIR, today_str):
|
||||
from datetime import datetime as dt_mod, date as date_mod
|
||||
from pathlib import Path as PathMod
|
||||
import json as json_mod
|
||||
import re as re_mod
|
||||
MODULE_META = {
|
||||
"scheduled_refresh_search_cache": {"name": "🔍 搜索缓存", "description": "通过 opencode webfetch 联网搜索,刷新 8 个分类的搜索缓存,供内容采集器使用"},
|
||||
"scheduled_fetch_trends": {"name": "🔥 热点趋势", "description": "从百度、微博、知乎实时热搜 API 抓取当天热点,LLM 补充,存入 trends.json"},
|
||||
@@ -279,7 +298,7 @@ def get_module_detail(module_id: str, db: Session = Depends(get_db), current_use
|
||||
pass
|
||||
|
||||
elif module_id == "scheduled_collect":
|
||||
from ..models import Topic, CollectorCategory
|
||||
from ..models import CollectorCategory
|
||||
pending = db.query(Topic).filter(Topic.status.in_(["pending", "待处理"])).count()
|
||||
total_topics = db.query(Topic).count()
|
||||
cats = db.query(CollectorCategory).filter(CollectorCategory.is_active == True).all()
|
||||
@@ -296,16 +315,19 @@ def get_module_detail(module_id: str, db: Session = Depends(get_db), current_use
|
||||
pending_t = db.query(Topic).filter(Topic.status.in_(["pending", "待处理"])).count()
|
||||
inputs["待创作选题"] = pending_t
|
||||
outputs["待审查"] = review
|
||||
from ..models import Article
|
||||
recent_articles = db.query(Article, Topic.title.label("topic_title")).join(Topic, Article.topic_id == Topic.id, isouter=True).order_by(Article.created_at.desc()).limit(5).all()
|
||||
outputs["最新文章"] = []
|
||||
seen_articles = set()
|
||||
for a in recent_articles:
|
||||
art = a.Article if hasattr(a, 'Article') else a[0]
|
||||
tid = a.topic_title if hasattr(a, 'topic_title') else (a[1] if len(a) > 1 else "")
|
||||
if art.id not in seen_articles:
|
||||
seen_articles.add(art.id)
|
||||
outputs["最新文章"].append({"id": art.id, "platform": art.platform, "topic": tid, "status": art.status, "created": art.created_at.isoformat() if art.created_at else ""})
|
||||
try:
|
||||
from ..models import Article
|
||||
recent_articles = db.query(Article, Topic.title.label("topic_title")).join(Topic, Article.topic_id == Topic.id, isouter=True).order_by(Article.created_at.desc()).limit(5).all()
|
||||
outputs["最新文章"] = []
|
||||
seen_articles = set()
|
||||
for a in recent_articles:
|
||||
art = a[0]
|
||||
tid = a[1] if len(a) > 1 else ""
|
||||
if art.id not in seen_articles:
|
||||
seen_articles.add(art.id)
|
||||
outputs["最新文章"].append({"id": art.id, "platform": art.platform, "topic": tid, "status": art.status, "created": art.created_at.isoformat() if art.created_at else ""})
|
||||
except Exception as e:
|
||||
outputs["最新文章_错误"] = str(e)
|
||||
|
||||
elif module_id == "scheduled_optimize":
|
||||
outputs["待审查选题"] = db.query(Topic).filter(Topic.status.in_(["review", "待审查"])).count()
|
||||
|
||||
Reference in New Issue
Block a user