Browse Source

add position to apptype:4

baichongyang 3 years ago
parent
commit
1415d34f32
2 changed files with 18 additions and 1 deletions
  1. 1 1
      config.py
  2. 17 0
      recommend.py

+ 1 - 1
config.py

@@ -12,7 +12,7 @@ class BaseConfig(object):
     # abTest
     AB_TEST = {
         'w_h_rate': [APP_TYPE['LONG_VIDEO']],  # 视频宽高比实验(每组的前两个视频调整为横屏视频)
-        'position_insert': [APP_TYPE['SHORT_VIDEO']]
+        'position_insert': [APP_TYPE['SHORT_VIDEO'],APP_TYPE['LOVE_LIVE']]
     }
     # abCode
     AB_CODE = {

+ 17 - 0
recommend.py

@@ -44,6 +44,8 @@ def video_position_recommend(mid, uid, app_type, videos):
     pos1_vids = filted_list[0]
     pos2_vids = filted_list[1]
 
+    videos = positon_duplicate(pos1_vids, pos2_vids, videos)    
+
     if pos1_vids is not None and len(pos1_vids) >0 :
         videos.insert(0, {'videoId': int(pos1_vids[0]), 'rovScore': 100,
                           'pushFrom': config_.PUSH_FROM['position_insert'], 'abCode': config_.AB_CODE['position_insert']})
@@ -54,6 +56,21 @@ def video_position_recommend(mid, uid, app_type, videos):
     return videos[:10]
 
 
+def positon_duplicate(pos1_vids, pos2_vids, videos):
+    s = set()
+    if pos1_vids is not None and len(pos1_vids) >0:
+        s.add(int(pos1_vids[0]))
+    if pos2_vids is not None and len(pos2_vids) >0:
+        s.add(int(pos2_vids[0]))
+
+    l = []
+    for i in range(len(videos)):
+        if videos[i]['videoId'] in s:
+            l.append(i)
+    for i in l:
+        videos.pop(i)
+    return videos
+
 def video_recommend(mid, uid, size, app_type, algo_type, client_info):
     """
     首页线上推荐逻辑