瀏覽代碼

获取素材和脚本任务 get_material_and_script 的定时任务添加 start_time 过滤条件

liyuyi@c-top.com.cn 3 年之前
父節點
當前提交
0ccbbcd16a
共有 2 個文件被更改,包括 7 次插入5 次删除
  1. 3 3
      routers/script_config.py
  2. 4 2
      time_task/get_material_and_script_by_query_word.py

+ 3 - 3
routers/script_config.py

@@ -50,7 +50,7 @@ class TaskDetail(BaseModel):
 class ConfigDetail(BaseModel):
     config_id: str = Field(..., description="脚本配置id")
     query_word: List[str] = Field(..., description="关键词")
-    recommended_word: List[str] = Field(..., description="推荐词")
+    recommended_word: List[str] = Field([""], description="推荐词")
     create_time: str = Field(..., description="创建时间")
     operator: str = Field(..., description="创建人")
     number: int = Field(..., description="序号")
@@ -401,9 +401,9 @@ def delete_script_config(item: DeleteScriptConfig):
              response_model=BaseResponse,
              description="获取素材和脚本任务",
              summary='获取素材和脚本任务')
-def get_material_and_script_time_task():
+def get_material_and_script_time_task(start_time: Optional[str] = ""):
     try:
-        get_material_and_script()
+        get_material_and_script(start_time)
         logger.info(f"{date.today().strftime('%Y-%m-%d')}, 获取素材和脚本任务执行完成.")
         return {"code": 0,
                 "success": True,

+ 4 - 2
time_task/get_material_and_script_by_query_word.py

@@ -18,7 +18,7 @@ from get_material_and_script.get_material_from_ocean_engine import GetMaterialFr
 from get_material_and_script.get_material_from_huichuang import GetMaterialFromHuiChuang
 
 
-def get_material_and_script():
+def get_material_and_script(start_time=""):
     # 1 读取配置文件
     with open('/data/pythonProject/video_to_word/config/config.yaml', mode='r', encoding='utf-8') as f:
         config = yaml.load(f.read(), Loader=yaml.FullLoader)
@@ -31,7 +31,9 @@ def get_material_and_script():
     source_name_map = config['source_name_map']
 
     # 2 读取查询表 + 推荐词
-    sql = f"select query_word, recommended_word from ctop_ai_script_query_word_config where end_time = '9999-12-31' and operate_type = 1"
+    start_time = '0000-00-00' if start_time == '' else start_time
+    sql = f"select query_word, recommended_word from ctop_ai_script_query_word_config where end_time = '9999-12-31' and operate_type = 1 " \
+          f"and start_time >= '{start_time}'"
     df = pd.read_sql(sql, ai_word_engine)
     query_word_set = set(df['query_word'].values)
     recommended_word_set = set(df['recommended_word'].values)