|
@@ -17,6 +17,7 @@ class historyContentIdTask(object):
|
|
|
"""
|
|
|
TASK_PROCESSING_STATUS = 101
|
|
|
EXIT_STATUS = 97
|
|
|
+ MISMATCH_STATUS = 96
|
|
|
TASK_INIT_STATUS = 0
|
|
|
TASK_PUBLISHED_STATUS = 4
|
|
|
|
|
@@ -31,6 +32,7 @@ class historyContentIdTask(object):
|
|
|
self.article_crawler_video_table = self.config.article_crawler_video_table
|
|
|
self.gh_id_dict = json.loads(self.config.get_config_value("testAccountLevel2"))
|
|
|
self.history_coroutines = self.config.get_config_value("historyArticleCoroutines")
|
|
|
+ self.account_negative_category = json.loads(self.config.get_config_value("account_negative_category"))
|
|
|
|
|
|
async def get_tasks(self):
|
|
|
"""
|
|
@@ -257,6 +259,27 @@ class historyContentIdTask(object):
|
|
|
else:
|
|
|
return False
|
|
|
|
|
|
+ async def check_title_category(self, content_id, gh_id) -> bool:
|
|
|
+ """
|
|
|
+ 判断该文章的品类是否属于该账号的品类
|
|
|
+ :param content_id:
|
|
|
+ :param gh_id:
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ bad_category_set = set(self.account_negative_category.get(gh_id, []))
|
|
|
+ if bad_category_set:
|
|
|
+ sql = f"""
|
|
|
+ SELECT category
|
|
|
+ FROM article_category
|
|
|
+ WHERE produce_content_id = '{content_id}';
|
|
|
+ """
|
|
|
+ result = await self.mysql_client.async_select(sql)
|
|
|
+ if result:
|
|
|
+ category = result[0][0]
|
|
|
+ if category in bad_category_set:
|
|
|
+ return True
|
|
|
+ return False
|
|
|
+
|
|
|
async def process_task(self, params):
|
|
|
"""
|
|
|
异步执行
|
|
@@ -266,7 +289,21 @@ class historyContentIdTask(object):
|
|
|
content_id = params['content_id']
|
|
|
trace_id = params['trace_id']
|
|
|
flow_pool_level = params['flow_pool_level']
|
|
|
+ gh_id = params['gh_id']
|
|
|
if flow_pool_level == "autoArticlePoolLevel4":
|
|
|
+ # 校验文章是否属于该账号的negative 类型
|
|
|
+ negative_category_status = await self.check_title_category(content_id=content_id, gh_id=gh_id)
|
|
|
+ if negative_category_status:
|
|
|
+ # 修改状态为品类不匹配状态
|
|
|
+ affected_rows = await self.update_content_status(
|
|
|
+ trace_id=trace_id,
|
|
|
+ new_content_status=self.MISMATCH_STATUS,
|
|
|
+ ori_content_status=self.TASK_INIT_STATUS
|
|
|
+ )
|
|
|
+ if affected_rows == 0:
|
|
|
+ print("修改行数为 0,多个进程抢占同一个 task, 抢占失败,进程退出")
|
|
|
+ return
|
|
|
+ # 校验文章是否晋升 or 退场
|
|
|
exit_status = await self.check_title_whether_exit(content_id)
|
|
|
if exit_status:
|
|
|
# 修改状态为退出状态
|