浏览代码

2024-10-21 developing rank by fission0 on read

__init__.py
add new table: long_articles_videos_fission_info
luojunhui 6 月之前
父节点
当前提交
5c7b046c6f
共有 2 个文件被更改,包括 35 次插入0 次删除
  1. 3 0
      applications/config/__init__.py
  2. 32 0
      applications/match_algorithm/rank.py

+ 3 - 0
applications/config/__init__.py

@@ -25,6 +25,7 @@ class Config(object):
                 self.article_crawler_video_table = "long_articles_crawler_videos"
                 self.root_source_id_table = "long_articles_root_source_id"
                 self.get_off_video_table = "get_off_videos"
+                self.fission_detail_table = "long_articles_videos_fission_info"
             case "dev":
                 self.apollo_connection = pyapollos.ApolloClient(
                     app_id="LongArticlesMatchServer",
@@ -36,6 +37,7 @@ class Config(object):
                 self.article_crawler_video_table = "long_articles_crawler_videos_copy1"
                 self.root_source_id_table = "long_articles_root_source_id_copy1"
                 self.get_off_video_table = "get_off_videos_copy1"
+                self.fission_detail_table = "long_articles_videos_fission_info_copy1"
             case "pre":
                 self.apollo_connection = pyapollos.ApolloClient(
                     app_id="LongArticlesMatchServer",
@@ -47,6 +49,7 @@ class Config(object):
                 self.article_crawler_video_table = "long_articles_crawler_videos"
                 self.root_source_id_table = "long_articles_root_source_id"
                 self.get_off_video_table = "get_off_videos"
+                self.fission_detail_table = "long_articles_videos_fission_info"
 
     def get_config_value(self, key):
         """

+ 32 - 0
applications/match_algorithm/rank.py

@@ -1,6 +1,8 @@
 """
 @author: luojunhui
 """
+from datetime import datetime, timedelta
+
 from applications.match_algorithm.title_similarity import jcd_title_similarity
 
 
@@ -51,3 +53,33 @@ def title_similarity_rank(content_title, recall_list):
         include_title_list.append(item)
     sorted_list = sorted(include_title_list, key=lambda x: x['score'], reverse=True)
     return sorted_list
+
+
+def rank_by_fission_info(db_client, config, content_id):
+    """
+    通过 content_id 对应的 oss 路径对应的裂变表现进行排序
+    oss 数据每天凌晨 2 点更新
+    :return:
+    """
+    FISSION_DETAIL_TABLE = config.fission_detail_table
+    yesterday_str = (datetime.now() - timedelta(days=1)).strftime('%Y%m%d')
+    sql = f"""
+        SELECT 
+            oss_name, fission_0_on_read
+        FROM
+            {FISSION_DETAIL_TABLE}
+        WHERE content_id = '{content_id}' and dt = '{yesterday_str}'
+        ORDER BY fission_0_on_read DESC;
+    """
+    result = db_client.select(sql)
+    if result:
+        oss_name_list = [i[0] for i in result]
+        return oss_name_list
+    else:
+        return
+
+
+
+
+
+