Browse Source

初始化的时候传publish_flag

luojunhui 5 months ago
parent
commit
161e57acea
2 changed files with 8 additions and 8 deletions
  1. 1 1
      historyTask.py
  2. 7 7
      tasks/history_task.py

+ 1 - 1
historyTask.py

@@ -49,7 +49,7 @@ async def do_job(publish_flag):
             }
         )
     try:
-        history_content_id_task = historyContentIdTask(async_mysql_pool)
+        history_content_id_task = historyContentIdTask(async_mysql_pool, publish_flag)
     except Exception as e:
         logging(
             code="history0003",

+ 7 - 7
tasks/history_task.py

@@ -19,7 +19,7 @@ class historyContentIdTask(object):
     处理已经匹配过小程序的文章
     """
 
-    def __init__(self, mysql_client):
+    def __init__(self, mysql_client, publish_flag):
         """
         :param mysql_client:
         """
@@ -32,8 +32,9 @@ class historyContentIdTask(object):
         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"))
+        self.publish_flag = publish_flag
 
-    async def get_tasks(self, publish_flag):
+    async def get_tasks(self):
         """
         获取任务
         :return:
@@ -54,11 +55,10 @@ class historyContentIdTask(object):
                 group by content_id
             ) VID on ART.content_id = VID.content_id and VID.cnt >= 3
             WHERE ART.content_status = {self.const.TASK_INIT_STATUS} and ART.process_times <= {self.const.TASK_MAX_PROCESS_TIMES}
-                AND publish_flag = {publish_flag}
+                AND ART.publish_flag = {self.publish_flag}
             ORDER BY ART.flow_pool_level, ART.request_timestamp
             LIMIT {self.history_coroutines};
         """
-        print(select_sql1)
         tasks = await self.mysql_client.async_select(sql=select_sql1)
         task_obj_list = [
             {
@@ -424,16 +424,16 @@ class historyContentIdTask(object):
         else:
             return
 
-    async def deal(self, publish_flag):
+    async def deal(self):
         """
         处理
         :return:
         """
-        task_list = await self.get_tasks(publish_flag=publish_flag)
+        task_list = await self.get_tasks()
         logging(
             code="history1001",
             info="History content_task Task Got {} this time".format(len(task_list)),
-            function="History Contents Task {}".format(publish_flag)
+            function="History Contents Task {}".format(self.publish_flag)
         )
         if task_list:
             a = time.time()