|
@@ -15,7 +15,7 @@ from sqlalchemy import desc, or_
|
|
|
|
|
|
|
|
from examples.demand.changwen_prepare import changwen_prepare
|
|
from examples.demand.changwen_prepare import changwen_prepare
|
|
|
from examples.demand.config import LOG_LEVEL, ENABLED_TOOLS
|
|
from examples.demand.config import LOG_LEVEL, ENABLED_TOOLS
|
|
|
-from examples.demand.db_manager import DatabaseManager
|
|
|
|
|
|
|
+from examples.demand.db_manager import DatabaseManager, query_video_ids_by_names
|
|
|
from examples.demand.models import TopicPatternExecution
|
|
from examples.demand.models import TopicPatternExecution
|
|
|
from examples.demand.piaoquan_prepare import prepare, piaoquan_prepare
|
|
from examples.demand.piaoquan_prepare import prepare, piaoquan_prepare
|
|
|
from examples.demand.demand_agent_context import TopicBuildAgentContext
|
|
from examples.demand.demand_agent_context import TopicBuildAgentContext
|
|
@@ -181,6 +181,14 @@ def _avg_score_for_joined_name(name: str, score_map: dict) -> float:
|
|
|
return sum(float(score_map.get(part, 0.0)) for part in parts) / len(parts)
|
|
return sum(float(score_map.get(part, 0.0)) for part in parts) / len(parts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def _resolve_video_ids_by_name_and_execution_id(name: str, execution_id: int) -> list[str]:
|
|
|
|
|
+ """按 name(逗号分隔) 与 execution_id 解析去重后的 post_id 列表。"""
|
|
|
|
|
+ name_parts = [part.strip() for part in str(name).split(",") if part and part.strip()]
|
|
|
|
|
+ if not name_parts:
|
|
|
|
|
+ return []
|
|
|
|
|
+ return query_video_ids_by_names(execution_id=execution_id, names=name_parts)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def _create_demand_task(
|
|
def _create_demand_task(
|
|
|
execution_id: int,
|
|
execution_id: int,
|
|
|
name: Optional[str] = None,
|
|
name: Optional[str] = None,
|
|
@@ -282,9 +290,11 @@ def write_demand_items_to_mysql(execution_id: int, merge_level2: str) -> int:
|
|
|
score = _avg_score_for_joined_name(name, score_map)
|
|
score = _avg_score_for_joined_name(name, score_map)
|
|
|
reason = di.get("reason")
|
|
reason = di.get("reason")
|
|
|
desc_value = di.get("desc")
|
|
desc_value = di.get("desc")
|
|
|
|
|
+ type = di.get("type")
|
|
|
suggestion = desc_value
|
|
suggestion = desc_value
|
|
|
|
|
+ video_ids = _resolve_video_ids_by_name_and_execution_id(name=name, execution_id=execution_id)
|
|
|
# 兼容旧字段:同时保留 ext_data(reason/desc)JSON,便于旧版消费逻辑迁移期继续使用。
|
|
# 兼容旧字段:同时保留 ext_data(reason/desc)JSON,便于旧版消费逻辑迁移期继续使用。
|
|
|
- ext_data = {"reason": reason, "desc": desc_value}
|
|
|
|
|
|
|
+ ext_data = {"reason": reason, "desc": desc_value, "type": type, "video_ids": video_ids}
|
|
|
|
|
|
|
|
rows.append(
|
|
rows.append(
|
|
|
{
|
|
{
|
|
@@ -409,7 +419,7 @@ async def run_once(execution_id, merge_level2, task_id: Optional[int] = None) ->
|
|
|
except Exception:
|
|
except Exception:
|
|
|
# 兜底:即使写文件失败,也要确保 MySQL 状态被更新
|
|
# 兜底:即使写文件失败,也要确保 MySQL 状态被更新
|
|
|
pass
|
|
pass
|
|
|
- _finish_demand_task(task_id=task_id, status=task_status, task_log=task_log_text)
|
|
|
|
|
|
|
+ # _finish_demand_task(task_id=task_id, status=task_status, task_log=task_log_text)
|
|
|
|
|
|
|
|
return final_text
|
|
return final_text
|
|
|
|
|
|
|
@@ -437,6 +447,6 @@ async def main(
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
|
- # asyncio.run(run_once(8, '贪污腐败'))
|
|
|
|
|
- write_demand_items_to_mysql(execution_id=8, merge_level2='贪污腐败')
|
|
|
|
|
|
|
+ asyncio.run(main('贪污腐败','piaoquan'))
|
|
|
|
|
+ # write_demand_items_to_mysql(execution_id=8, merge_level2='贪污腐败')
|
|
|
|
|
|