|
@@ -4,7 +4,7 @@
|
|
|
import json
|
|
|
import time
|
|
|
|
|
|
-from applications.config import Config
|
|
|
+from applications.config import Config, NewContentIdTaskConst
|
|
|
from applications.log import logging
|
|
|
from applications.functions.pqFunctions import publish_to_pq, get_pq_video_detail
|
|
|
from applications.functions.common import shuffle_list
|
|
@@ -19,17 +19,6 @@ class NewContentIdTask(object):
|
|
|
"""
|
|
|
不存在历史已经发布的文章的匹配流程
|
|
|
"""
|
|
|
- TASK_INIT_STATUS = 0
|
|
|
- TASK_KIMI_FINISHED_STATUS = 1
|
|
|
- TASK_SPIDER_FINISHED_STATUS = 2
|
|
|
- TASK_ETL_FINISHED_STATUS = 3
|
|
|
- TASK_PUBLISHED_STATUS = 4
|
|
|
- TASK_PROCESSING_STATUS = 101
|
|
|
- TASK_FAIL_STATUS = 99
|
|
|
- KIMI_ILLEGAL_STATUS = 95
|
|
|
- ARTICLE_TEXT_TABLE_ERROR = 98
|
|
|
- TASK_MAX_PROCESS_TIMES = 3
|
|
|
- RECORD_SUCCESS_TRACE_ID_CODE = 2
|
|
|
|
|
|
def __init__(self, mysql_client):
|
|
|
self.mysql_client = mysql_client
|
|
@@ -41,6 +30,7 @@ class NewContentIdTask(object):
|
|
|
self.account_map = json.loads(self.config.get_config_value("accountMap"))
|
|
|
self.spider_coroutines = self.config.get_config_value("spiderCoroutines")
|
|
|
self.new_method_gh_id = json.loads(self.config.get_config_value("newMethodGhId"))
|
|
|
+ self.const = NewContentIdTaskConst()
|
|
|
|
|
|
async def get_tasks(self):
|
|
|
"""
|
|
@@ -54,8 +44,8 @@ class NewContentIdTask(object):
|
|
|
FROM
|
|
|
{self.article_match_video_table}
|
|
|
WHERE
|
|
|
- content_status = {self.TASK_PROCESSING_STATUS}
|
|
|
- and process_times <= {self.TASK_MAX_PROCESS_TIMES};
|
|
|
+ content_status = {self.const.TASK_PROCESSING_STATUS}
|
|
|
+ and process_times <= {self.const.TASK_MAX_PROCESS_TIMES};
|
|
|
"""
|
|
|
processing_articles = await self.mysql_client.async_select(select_processing_sql)
|
|
|
if processing_articles:
|
|
@@ -68,38 +58,39 @@ class NewContentIdTask(object):
|
|
|
for item in processing_articles
|
|
|
]
|
|
|
for obj in processing_list:
|
|
|
- if int(time.time()) - obj['content_status_update_time'] >= 3600:
|
|
|
+ if int(time.time()) - obj['content_status_update_time'] >= self.const.TASK_PROCESSING_TIMEOUT:
|
|
|
# 认为该任务失败
|
|
|
await self.roll_back_content_status_when_fails(
|
|
|
process_times=obj['process_times'] + 1,
|
|
|
trace_id=obj['trace_id']
|
|
|
)
|
|
|
- # 将 process_times > 3 且状态不为 4 的任务的状态修改为失败,
|
|
|
+ # 将 process_times > 3 且状态不为 4 的任务的状态修改为失败, 判断条件需要加上索引
|
|
|
update_status_sql = f"""
|
|
|
UPDATE
|
|
|
{self.article_match_video_table}
|
|
|
SET
|
|
|
content_status = %s
|
|
|
WHERE
|
|
|
- process_times > %s and content_status != %s;
|
|
|
+ process_times > %s and content_status not in (%s, %s);
|
|
|
"""
|
|
|
await self.mysql_client.async_insert(
|
|
|
update_status_sql,
|
|
|
params=(
|
|
|
- self.TASK_FAIL_STATUS,
|
|
|
- self.TASK_MAX_PROCESS_TIMES,
|
|
|
- self.TASK_PUBLISHED_STATUS
|
|
|
+ self.const.TASK_FAIL_STATUS,
|
|
|
+ self.const.TASK_MAX_PROCESS_TIMES,
|
|
|
+ self.const.TASK_ETL_COMPLETE_STATUS,
|
|
|
+ self.const.TASK_PUBLISHED_STATUS
|
|
|
)
|
|
|
)
|
|
|
# 获取 process_times <= 3 且 content_status = 0 的任务
|
|
|
select_sql = f"""
|
|
|
SELECT
|
|
|
- trace_id, content_id, flow_pool_level, gh_id, process_times
|
|
|
+ trace_id, content_id, flow_pool_level, gh_id, process_times, publish_flag
|
|
|
FROM
|
|
|
{self.article_match_video_table}
|
|
|
WHERE
|
|
|
- content_status = {self.TASK_INIT_STATUS}
|
|
|
- and process_times <= {self.TASK_MAX_PROCESS_TIMES}
|
|
|
+ content_status = {self.const.TASK_INIT_STATUS}
|
|
|
+ and process_times <= {self.const.TASK_MAX_PROCESS_TIMES}
|
|
|
ORDER BY flow_pool_level, request_timestamp
|
|
|
LIMIT {self.spider_coroutines};
|
|
|
"""
|
|
@@ -111,7 +102,8 @@ class NewContentIdTask(object):
|
|
|
"content_id": i[1],
|
|
|
"flow_pool_level": i[2],
|
|
|
"gh_id": i[3],
|
|
|
- "process_times": i[4]
|
|
|
+ "process_times": i[4],
|
|
|
+ "publish_flag": i[5]
|
|
|
}
|
|
|
for i in tasks
|
|
|
]
|
|
@@ -127,10 +119,10 @@ class NewContentIdTask(object):
|
|
|
sql = f"""
|
|
|
SELECT id
|
|
|
FROM {self.article_crawler_video_table}
|
|
|
- WHERE content_id = '{content_id}' and download_status = 2;
|
|
|
+ WHERE content_id = '{content_id}' and download_status = {self.const.VIDEO_DOWNLOAD_SUCCESS_STATUS};
|
|
|
"""
|
|
|
res_tuple = await self.mysql_client.async_select(sql)
|
|
|
- if len(res_tuple) >= 3:
|
|
|
+ if len(res_tuple) >= self.const.MIN_MATCH_VIDEO_NUM:
|
|
|
return True
|
|
|
else:
|
|
|
return False
|
|
@@ -176,11 +168,11 @@ class NewContentIdTask(object):
|
|
|
await self.mysql_client.async_insert(
|
|
|
sql=update_article_sql,
|
|
|
params=(
|
|
|
- self.TASK_INIT_STATUS,
|
|
|
+ self.const.TASK_INIT_STATUS,
|
|
|
int(time.time()),
|
|
|
process_times + 1,
|
|
|
trace_id,
|
|
|
- self.TASK_PROCESSING_STATUS
|
|
|
+ self.const.TASK_PROCESSING_STATUS
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -192,6 +184,7 @@ class NewContentIdTask(object):
|
|
|
success: 4
|
|
|
init: 0
|
|
|
fail: 99
|
|
|
+ todo: 存在处理失败的content_id是否需要不再处理
|
|
|
"""
|
|
|
select_sql = f"""
|
|
|
SELECT distinct content_status
|
|
@@ -204,11 +197,11 @@ class NewContentIdTask(object):
|
|
|
content_status = item[0]
|
|
|
# if content_status not in {self.TASK_INIT_STATUS, self.TASK_PUBLISHED_STATUS} :
|
|
|
if content_status in {
|
|
|
- self.TASK_KIMI_FINISHED_STATUS,
|
|
|
- self.TASK_SPIDER_FINISHED_STATUS,
|
|
|
- self.TASK_ETL_FINISHED_STATUS,
|
|
|
- self.TASK_PROCESSING_STATUS,
|
|
|
- self.TASK_PUBLISHED_STATUS
|
|
|
+ self.const.TASK_KIMI_FINISHED_STATUS,
|
|
|
+ self.const.TASK_SPIDER_FINISHED_STATUS,
|
|
|
+ self.const.TASK_ETL_COMPLETE_STATUS,
|
|
|
+ self.const.TASK_PROCESSING_STATUS,
|
|
|
+ self.const.TASK_PUBLISHED_STATUS
|
|
|
}:
|
|
|
return True
|
|
|
return False
|
|
@@ -223,7 +216,7 @@ class NewContentIdTask(object):
|
|
|
sql = f"""
|
|
|
SELECT platform, play_count, like_count, video_oss_path, cover_oss_path, user_id
|
|
|
FROM {self.article_crawler_video_table}
|
|
|
- WHERE content_id = '{content_id}' and download_status = 2
|
|
|
+ WHERE content_id = '{content_id}' and download_status = {self.const.VIDEO_DOWNLOAD_SUCCESS_STATUS};
|
|
|
ORDER BY score DESC;
|
|
|
"""
|
|
|
res_tuple = await self.mysql_client.async_select(sql)
|
|
@@ -254,25 +247,23 @@ class NewContentIdTask(object):
|
|
|
kimi_status = response[0][0]
|
|
|
return kimi_status
|
|
|
else:
|
|
|
- return self.ARTICLE_TEXT_TABLE_ERROR
|
|
|
+ return self.const.ARTICLE_TEXT_TABLE_ERROR
|
|
|
|
|
|
async def kimi_task(self, params):
|
|
|
"""
|
|
|
执行 kimi 任务
|
|
|
:return:
|
|
|
"""
|
|
|
- KIMI_SUCCESS_STATUS = 1
|
|
|
- KIMI_FAIL_STATUS = 2
|
|
|
content_id = params['content_id']
|
|
|
trace_id = params['trace_id']
|
|
|
process_times = params['process_times']
|
|
|
kimi_status_code = await self.get_kimi_status(content_id=content_id)
|
|
|
|
|
|
- if kimi_status_code == KIMI_SUCCESS_STATUS:
|
|
|
+ if kimi_status_code == self.const.KIMI_SUCCESS_STATUS:
|
|
|
affected_rows = await self.update_content_status(
|
|
|
- new_content_status=self.TASK_KIMI_FINISHED_STATUS,
|
|
|
+ new_content_status=self.const.TASK_KIMI_FINISHED_STATUS,
|
|
|
trace_id=trace_id,
|
|
|
- ori_content_status=self.TASK_INIT_STATUS
|
|
|
+ ori_content_status=self.const.TASK_INIT_STATUS
|
|
|
)
|
|
|
if affected_rows == 0:
|
|
|
logging(
|
|
@@ -292,7 +283,7 @@ class NewContentIdTask(object):
|
|
|
"kimi_summary": kimi_info[0][2],
|
|
|
"kimi_keys": json.loads(kimi_info[0][3])
|
|
|
}
|
|
|
- elif kimi_status_code == self.ARTICLE_TEXT_TABLE_ERROR:
|
|
|
+ elif kimi_status_code == self.const.ARTICLE_TEXT_TABLE_ERROR:
|
|
|
logging(
|
|
|
code="4000",
|
|
|
info="long_articles_text表中未找到 content_id"
|
|
@@ -300,9 +291,9 @@ class NewContentIdTask(object):
|
|
|
else:
|
|
|
# 开始处理,讲 content_status 从 0 改为 101
|
|
|
affected_rows = await self.update_content_status(
|
|
|
- new_content_status=self.TASK_PROCESSING_STATUS,
|
|
|
+ new_content_status=self.const.TASK_PROCESSING_STATUS,
|
|
|
trace_id=trace_id,
|
|
|
- ori_content_status=self.TASK_INIT_STATUS
|
|
|
+ ori_content_status=self.const.TASK_INIT_STATUS
|
|
|
)
|
|
|
if affected_rows == 0:
|
|
|
logging(
|
|
@@ -337,12 +328,12 @@ class NewContentIdTask(object):
|
|
|
WHERE content_id = %s;"""
|
|
|
await self.mysql_client.async_insert(
|
|
|
sql=update_kimi_sql,
|
|
|
- params=(kimi_title, content_title, content_keys, KIMI_SUCCESS_STATUS, params['content_id'])
|
|
|
+ params=(kimi_title, content_title, content_keys, self.const.KIMI_SUCCESS_STATUS, params['content_id'])
|
|
|
)
|
|
|
await self.update_content_status(
|
|
|
- new_content_status=self.TASK_KIMI_FINISHED_STATUS,
|
|
|
+ new_content_status=self.const.TASK_KIMI_FINISHED_STATUS,
|
|
|
trace_id=trace_id,
|
|
|
- ori_content_status=self.TASK_PROCESSING_STATUS
|
|
|
+ ori_content_status=self.const.TASK_PROCESSING_STATUS
|
|
|
)
|
|
|
return {
|
|
|
"kimi_title": kimi_title,
|
|
@@ -361,7 +352,7 @@ class NewContentIdTask(object):
|
|
|
await self.mysql_client.async_insert(
|
|
|
sql=update_kimi_sql,
|
|
|
params=(
|
|
|
- KIMI_FAIL_STATUS,
|
|
|
+ self.const.KIMI_FAIL_STATUS,
|
|
|
content_id
|
|
|
)
|
|
|
)
|
|
@@ -377,31 +368,29 @@ class NewContentIdTask(object):
|
|
|
爬虫任务
|
|
|
:return:
|
|
|
"""
|
|
|
- SPIDER_INIT_STATUS = 1
|
|
|
- DOWNLOAD_SUCCESS_STATUS = 2
|
|
|
trace_id = params['trace_id']
|
|
|
content_id = params['content_id']
|
|
|
process_times = params['process_times']
|
|
|
gh_id = params['gh_id']
|
|
|
select_sql = f"""
|
|
|
- select count(id)
|
|
|
- from {self.article_crawler_video_table}
|
|
|
- where content_id = '{content_id}'
|
|
|
- and download_status = {DOWNLOAD_SUCCESS_STATUS};
|
|
|
+ SELECT count(id)
|
|
|
+ FROM {self.article_crawler_video_table}
|
|
|
+ WHERE content_id = '{content_id}'
|
|
|
+ AND download_status = {self.const.VIDEO_DOWNLOAD_SUCCESS_STATUS};
|
|
|
"""
|
|
|
count_tuple = await self.mysql_client.async_select(select_sql)
|
|
|
counts = count_tuple[0][0]
|
|
|
- if counts >= 3:
|
|
|
+ if counts >= self.const.MIN_MATCH_VIDEO_NUM:
|
|
|
await self.update_content_status(
|
|
|
- new_content_status=self.TASK_SPIDER_FINISHED_STATUS,
|
|
|
+ new_content_status=self.const.TASK_SPIDER_FINISHED_STATUS,
|
|
|
trace_id=trace_id,
|
|
|
- ori_content_status=SPIDER_INIT_STATUS
|
|
|
+ ori_content_status=self.const.TASK_KIMI_FINISHED_STATUS
|
|
|
)
|
|
|
return True
|
|
|
# 开始处理,将状态由 1 改成 101
|
|
|
affected_rows = await self.update_content_status(
|
|
|
- new_content_status=self.TASK_PROCESSING_STATUS,
|
|
|
- ori_content_status=SPIDER_INIT_STATUS,
|
|
|
+ new_content_status=self.const.TASK_PROCESSING_STATUS,
|
|
|
+ ori_content_status=self.const.TASK_KIMI_FINISHED_STATUS,
|
|
|
trace_id=trace_id
|
|
|
)
|
|
|
if affected_rows == 0:
|
|
@@ -430,7 +419,7 @@ class NewContentIdTask(object):
|
|
|
gh_id_map=self.account_map,
|
|
|
db_client=self.mysql_client
|
|
|
)
|
|
|
- if search_videos_count >= 3:
|
|
|
+ if search_videos_count >= self.const.MIN_MATCH_VIDEO_NUM:
|
|
|
# 表示爬虫任务执行成功, 将状态从 101 改为 2
|
|
|
logging(
|
|
|
code="spider_1002",
|
|
@@ -439,9 +428,9 @@ class NewContentIdTask(object):
|
|
|
data=kimi_result
|
|
|
)
|
|
|
await self.update_content_status(
|
|
|
- new_content_status=self.TASK_SPIDER_FINISHED_STATUS,
|
|
|
+ new_content_status=self.const.TASK_SPIDER_FINISHED_STATUS,
|
|
|
trace_id=trace_id,
|
|
|
- ori_content_status=self.TASK_PROCESSING_STATUS
|
|
|
+ ori_content_status=self.const.TASK_PROCESSING_STATUS
|
|
|
)
|
|
|
return True
|
|
|
else:
|
|
@@ -470,9 +459,6 @@ class NewContentIdTask(object):
|
|
|
:param params:
|
|
|
:return:
|
|
|
"""
|
|
|
- VIDEO_DOWNLOAD_SUCCESS_STATUS = 2
|
|
|
- VIDEO_DOWNLOAD_FAIL_STATUS = 3
|
|
|
- ETL_TASK_INIT_STATUS = 2
|
|
|
trace_id = params['trace_id']
|
|
|
content_id = params['content_id']
|
|
|
process_times = params['process_times']
|
|
@@ -480,15 +466,15 @@ class NewContentIdTask(object):
|
|
|
select_sql = f"""
|
|
|
select count(id)
|
|
|
from {self.article_crawler_video_table}
|
|
|
- where content_id = '{content_id}' and download_status = {VIDEO_DOWNLOAD_SUCCESS_STATUS};
|
|
|
+ where content_id = '{content_id}' and download_status = {self.const.VIDEO_DOWNLOAD_SUCCESS_STATUS};
|
|
|
"""
|
|
|
video_count_tuple = await self.mysql_client.async_select(select_sql)
|
|
|
video_count = video_count_tuple[0][0]
|
|
|
- if video_count >= 3:
|
|
|
+ if video_count >= self.const.MIN_MATCH_VIDEO_NUM:
|
|
|
affect_rows = await self.update_content_status(
|
|
|
- ori_content_status=ETL_TASK_INIT_STATUS,
|
|
|
+ ori_content_status=self.const.TASK_SPIDER_FINISHED_STATUS,
|
|
|
trace_id=trace_id,
|
|
|
- new_content_status=self.TASK_ETL_FINISHED_STATUS
|
|
|
+ new_content_status=self.const.TASK_ETL_COMPLETE_STATUS
|
|
|
)
|
|
|
if affect_rows == 0:
|
|
|
logging(
|
|
@@ -500,9 +486,9 @@ class NewContentIdTask(object):
|
|
|
else:
|
|
|
# 开始处理, 将文章状态修改为处理状态
|
|
|
affected_rows = await self.update_content_status(
|
|
|
- ori_content_status=ETL_TASK_INIT_STATUS,
|
|
|
+ ori_content_status=self.const.TASK_SPIDER_FINISHED_STATUS,
|
|
|
trace_id=trace_id,
|
|
|
- new_content_status=self.TASK_PROCESSING_STATUS
|
|
|
+ new_content_status=self.const.TASK_PROCESSING_STATUS
|
|
|
)
|
|
|
if affected_rows == 0:
|
|
|
logging(
|
|
@@ -513,7 +499,7 @@ class NewContentIdTask(object):
|
|
|
select_sql = f"""
|
|
|
SELECT id, out_video_id, platform, video_title, video_url, cover_url, user_id, trace_id
|
|
|
FROM {self.article_crawler_video_table}
|
|
|
- WHERE content_id = '{content_id}' and download_status != {VIDEO_DOWNLOAD_SUCCESS_STATUS}
|
|
|
+ WHERE content_id = '{content_id}' and download_status != {self.const.VIDEO_DOWNLOAD_SUCCESS_STATUS}
|
|
|
ORDER BY score DESC;
|
|
|
"""
|
|
|
videos_need_to_download_tuple = await self.mysql_client.async_select(select_sql)
|
|
@@ -546,7 +532,7 @@ class NewContentIdTask(object):
|
|
|
"""
|
|
|
await self.mysql_client.async_insert(
|
|
|
sql=update_sql,
|
|
|
- params=(VIDEO_DOWNLOAD_FAIL_STATUS, params['id'])
|
|
|
+ params=(self.const.VIDEO_DOWNLOAD_FAIL_STATUS, params['id'])
|
|
|
)
|
|
|
logging(
|
|
|
code="etl_1001",
|
|
@@ -586,7 +572,7 @@ class NewContentIdTask(object):
|
|
|
params=(
|
|
|
oss_video,
|
|
|
oss_cover,
|
|
|
- VIDEO_DOWNLOAD_SUCCESS_STATUS,
|
|
|
+ self.const.VIDEO_DOWNLOAD_SUCCESS_STATUS,
|
|
|
params['id']
|
|
|
)
|
|
|
)
|
|
@@ -598,11 +584,11 @@ class NewContentIdTask(object):
|
|
|
function="etl_task"
|
|
|
)
|
|
|
# 如果下载的视频数已经大于3, 则直接退出循环,修改状态为ETL成功状态
|
|
|
- if downloaded_count > 3:
|
|
|
+ if downloaded_count > self.const.MIN_MATCH_VIDEO_NUM:
|
|
|
await self.update_content_status(
|
|
|
- ori_content_status=self.TASK_PROCESSING_STATUS,
|
|
|
+ ori_content_status=self.const.TASK_PROCESSING_STATUS,
|
|
|
trace_id=trace_id,
|
|
|
- new_content_status=self.TASK_ETL_FINISHED_STATUS
|
|
|
+ new_content_status=self.const.TASK_ETL_COMPLETE_STATUS
|
|
|
)
|
|
|
return True
|
|
|
except Exception as e:
|
|
@@ -613,7 +599,7 @@ class NewContentIdTask(object):
|
|
|
"""
|
|
|
await self.mysql_client.async_insert(
|
|
|
sql=update_sql,
|
|
|
- params=(VIDEO_DOWNLOAD_FAIL_STATUS, params['id'])
|
|
|
+ params=(self.const.VIDEO_DOWNLOAD_FAIL_STATUS, params['id'])
|
|
|
)
|
|
|
logging(
|
|
|
code="etl_1001",
|
|
@@ -623,9 +609,9 @@ class NewContentIdTask(object):
|
|
|
)
|
|
|
if downloaded_count >= 3:
|
|
|
await self.update_content_status(
|
|
|
- ori_content_status=self.TASK_PROCESSING_STATUS,
|
|
|
+ ori_content_status=self.const.TASK_PROCESSING_STATUS,
|
|
|
trace_id=trace_id,
|
|
|
- new_content_status=self.TASK_ETL_FINISHED_STATUS
|
|
|
+ new_content_status=self.const.TASK_ETL_COMPLETE_STATUS
|
|
|
)
|
|
|
return True
|
|
|
else:
|
|
@@ -642,7 +628,6 @@ class NewContentIdTask(object):
|
|
|
:param params:
|
|
|
:return:
|
|
|
"""
|
|
|
- PUBLISH_DEFAULT_STATUS = 3
|
|
|
gh_id = params['gh_id']
|
|
|
flow_pool_level = params['flow_pool_level']
|
|
|
content_id = params['content_id']
|
|
@@ -650,9 +635,9 @@ class NewContentIdTask(object):
|
|
|
process_times = params['process_times']
|
|
|
# 开始处理,将状态修改为操作状态
|
|
|
affected_rows = await self.update_content_status(
|
|
|
- ori_content_status=PUBLISH_DEFAULT_STATUS,
|
|
|
+ ori_content_status=self.const.TASK_ETL_COMPLETE_STATUS,
|
|
|
trace_id=trace_id,
|
|
|
- new_content_status=self.TASK_PROCESSING_STATUS
|
|
|
+ new_content_status=self.const.TASK_PROCESSING_STATUS
|
|
|
)
|
|
|
if affected_rows == 0:
|
|
|
logging(
|
|
@@ -708,11 +693,11 @@ class NewContentIdTask(object):
|
|
|
await self.mysql_client.async_insert(
|
|
|
sql=update_sql,
|
|
|
params=(
|
|
|
- self.TASK_PUBLISHED_STATUS,
|
|
|
+ self.const.TASK_PUBLISHED_STATUS,
|
|
|
json.dumps(L, ensure_ascii=False),
|
|
|
process_times + 1,
|
|
|
trace_id,
|
|
|
- self.TASK_PROCESSING_STATUS
|
|
|
+ self.const.TASK_PROCESSING_STATUS
|
|
|
)
|
|
|
)
|
|
|
except Exception as e:
|
|
@@ -735,6 +720,7 @@ class NewContentIdTask(object):
|
|
|
process_times = params['process_times']
|
|
|
content_id = params['content_id']
|
|
|
gh_id = params['gh_id']
|
|
|
+ publish_flag = params['publish_flag']
|
|
|
print(kimi_result)
|
|
|
if kimi_result:
|
|
|
# 等待 kimi 操作执行完成之后,开始执行 spider_task
|
|
@@ -762,10 +748,14 @@ class NewContentIdTask(object):
|
|
|
info="etl_success",
|
|
|
trace_id=trace_id
|
|
|
)
|
|
|
- if gh_id in self.new_method_gh_id:
|
|
|
+ """
|
|
|
+ todo 若新建计划,计划为设置托管,但接入账号又在配置账号中,仍会走托管逻辑,需考虑历史存量的处理
|
|
|
+ 目前先对这两种情况都做托管操作
|
|
|
+ """
|
|
|
+ if gh_id in self.new_method_gh_id or publish_flag == self.const.DO_NOT_NEED_PUBLISH:
|
|
|
logging(
|
|
|
code="3013",
|
|
|
- info="new_method_gh_id",
|
|
|
+ info="不需要发布,长文系统托管发布",
|
|
|
trace_id=trace_id
|
|
|
)
|
|
|
return
|
|
@@ -779,7 +769,7 @@ class NewContentIdTask(object):
|
|
|
)
|
|
|
await record_trace_id(
|
|
|
trace_id=trace_id,
|
|
|
- status=self.RECORD_SUCCESS_TRACE_ID_CODE
|
|
|
+ status=self.const.RECORD_SUCCESS_TRACE_ID_CODE
|
|
|
)
|
|
|
except Exception as e:
|
|
|
logging(
|
|
@@ -805,7 +795,7 @@ class NewContentIdTask(object):
|
|
|
info="kimi 处理失败",
|
|
|
trace_id=trace_id
|
|
|
)
|
|
|
- if process_times >= self.TASK_MAX_PROCESS_TIMES:
|
|
|
+ if process_times >= self.const.TASK_MAX_PROCESS_TIMES:
|
|
|
logging(
|
|
|
code="6011",
|
|
|
info="kimi处理次数达到上限, 放弃处理",
|
|
@@ -820,9 +810,9 @@ class NewContentIdTask(object):
|
|
|
affected_rows = await self.mysql_client.async_insert(
|
|
|
sql=update_sql,
|
|
|
params=(
|
|
|
- self.KIMI_ILLEGAL_STATUS,
|
|
|
+ self.const.KIMI_ILLEGAL_STATUS,
|
|
|
content_id,
|
|
|
- self.TASK_INIT_STATUS
|
|
|
+ self.const.TASK_INIT_STATUS
|
|
|
)
|
|
|
)
|
|
|
bot(
|