|
@@ -97,8 +97,8 @@ class QueryWordTaskInfoLst(BaseModel):
|
|
|
|
|
|
|
|
|
class QueryWordAndRecommendedWordPair(BaseModel):
|
|
|
- query_word: str = Field('红包', description='关键字')
|
|
|
- recommended_word: List[str] = Field(['推荐词1', '推荐词2'], description='推荐词')
|
|
|
+ query_word: str = Field(..., description='关键字')
|
|
|
+ recommended_word: List[str] = Field([], description='推荐词')
|
|
|
|
|
|
|
|
|
class AddScriptConfig(BaseModel):
|
|
@@ -109,7 +109,7 @@ class AddScriptConfig(BaseModel):
|
|
|
class Config:
|
|
|
schema_extra = {
|
|
|
"example": {
|
|
|
- "query_word_pair": [{"query_word": "红包", "recommended_word": ["购物券", "优惠券", "现金"]}],
|
|
|
+ "query_word_pair": [{"query_word": "水蜜桃", "recommended_word": ["我等你", "陌陌", "寻爱", "聊吧"]}],
|
|
|
"operator": "管理员",
|
|
|
"user_id": "e9ca23d68d884d4ebb19d07889727dae"
|
|
|
}
|
|
@@ -212,7 +212,8 @@ def get_script_config_lst(item: ScriptConfigLst):
|
|
|
sql = f"select * from ctop_ai_script_query_word_config where config_id in " \
|
|
|
f"(select distinct(config_id) config_id from ctop_ai_script_query_word_config " \
|
|
|
f"where start_time >= '{item.start_date}' and start_time < '{end_date}' " \
|
|
|
- f"and ('{item.search_word}' = '' or query_word like '%%{item.search_word}%%') or recommended_word like '%%{item.search_word}%%') "
|
|
|
+ f"and ('{item.search_word}' = '' or query_word like '%%{item.search_word}%%') or recommended_word like '%%{item.search_word}%%') " \
|
|
|
+ f"and operate_type = 1 and end_time ='9999-12-31'"
|
|
|
|
|
|
org_df = pd.read_sql(sql, ai_word_engine)
|
|
|
if not org_df.empty:
|
|
@@ -340,7 +341,7 @@ def add_script_config(item: AddScriptConfig):
|
|
|
for pair in item.query_word_pair:
|
|
|
config_id = str(uuid.uuid4())
|
|
|
config_df = pd.DataFrame({'query_word': pair.query_word,
|
|
|
- 'recommended_word': pair.recommended_word,
|
|
|
+ 'recommended_word': [None] if len(pair.recommended_word) == 0 else pair.recommended_word,
|
|
|
'config_id': config_id})
|
|
|
multi_config_df = multi_config_df.append(config_df)
|
|
|
|