Kaynağa Gözat

解构内部优质文章

luojunhui 4 gün önce
ebeveyn
işleme
7128a969b5

+ 14 - 9
app/domains/decode_task/inner_articles_decode/_mapper.py

@@ -120,14 +120,19 @@ class InnerArticlesDecodeMapper(InnerArticlesDecodeConst):
     # 获取内部文章
     async def fetch_inner_articles(self):
         query = """
-            SELECT source_id, title, wx_sn
-            FROM datastat_sort_strategy
-            WHERE date_str >= '20260101'
-                AND account_type != '服务号'
-                AND position = 1
-                AND source_id is not null
-            GROUP BY source_id
-            HAVING sum(view_count) / sum(avg_view_count) >= 1.2
-            AND min(read_rate) >= 0.2;
+            SELECT  title
+                  ,SUM(fans) AS total_fans
+                  ,SUM(view_count) AS total_view
+                  ,SUM(view_count) / SUM(fans) AS avg_read_rate
+                  ,SUM(first_level) AS total_first_level
+                  ,MAX(source_id) as source_id
+                  ,MAX(wx_sn) as wx_sn
+            FROM    datastat_sort_strategy
+            WHERE  date_str >= '20250101'
+            GROUP BY title
+            HAVING total_fans > 100000
+            AND     avg_read_rate > 0.008
+            AND     total_first_level > 0;
+
         """
         return await self.pool.async_fetch(query=query)