소스 검색

category model 优化

luojunhui 1 개월 전
부모
커밋
c8ed9884bd
2개의 변경된 파일56개의 추가작업 그리고 0개의 파일을 삭제
  1. 19 0
      app/infra/mapper/aigc_mapper.py
  2. 37 0
      app/infra/mapper/piaoquan_crawler_mapper.py

+ 19 - 0
app/infra/mapper/aigc_mapper.py

@@ -31,3 +31,22 @@ class AigcDatabaseMapper:
         return await pool.async_fetch(
             query=query, db_name="aigc", params=(channel_content_id, COVER_TYPE)
         )
+
+    # 从 AIGC 数据查询Daily发文账号信息
+    @staticmethod
+    async def get_daily_publish_accounts(pool: DatabaseManager) -> List[Dict]:
+        query = """
+            select distinct t3.name, t3.gh_id, t3.follower_count, t3.create_timestamp as account_init_timestamp,
+                t4.service_type_info as account_type, t4.verify_type_info as account_auth, t3.id as account_id,
+                group_concat(distinct t5.remark) as account_remark
+            from
+                publish_plan t1
+                join publish_plan_account t2 on t1.id = t2.plan_id
+                join publish_account t3 on t2.account_id = t3.id
+                left join publish_account_wx_type t4 on t3.id = t4.account_id
+                left join publish_account_remark t5 on t3.id = t5.publish_account_id
+            where t1.plan_status = 1 and t1.content_modal = 3 and t3.channel = 5
+            group by t3.id;
+        """
+        account_list = await pool.async_fetch(query, db_name="aigc")
+        return [i for i in account_list if "自动回复" not in str(i["account_remark"])]

+ 37 - 0
app/infra/mapper/piaoquan_crawler_mapper.py

@@ -0,0 +1,37 @@
+from typing import List, Dict
+
+from app.core.database import DatabaseManager
+
+
+class PiaoquanCrawlerDatabaseMapper:
+    # 兜底修改发文时间戳, 使用相同群发的msgID
+    @staticmethod
+    async def fallback_mechanism_by_msg_id(pool: DatabaseManager) -> int:
+        # 通过msgId 来修改publish_timestamp
+        query = """
+            UPDATE official_articles_v2 oav 
+            JOIN (
+                    SELECT ghId, appMsgId, MAX(publish_timestamp) AS publish_timestamp 
+                    FROM official_articles_v2
+                    WHERE publish_timestamp > %s 
+                    GROUP by ghId, appMsgId
+                ) vv 
+                ON oav.appMsgId = vv.appMsgId AND oav.ghId = vv.ghId
+            SET oav.publish_timestamp = vv.publish_timestamp
+            WHERE oav.publish_timestamp <= %s;
+        """
+        return await pool.async_save(
+            query=query, params=(0, 0), db_name="piaoquan_crawler"
+        )
+
+    # 兜底修改发文时间戳,使用 update_time
+    @staticmethod
+    async def fallback_mechanism_by_update_time(pool: DatabaseManager) -> int:
+        query = """
+            UPDATE official_articles_v2
+            SET publish_timestamp = updateTime
+            WHERE publish_timestamp < %s;
+        """
+        return await pool.async_save(
+            query=query, params=(0,), db_name="piaoquan_crawler"
+        )