Forráskód Böngészése

Merge branch 'w-h-rate' into test

liqian 3 éve
szülő
commit
ce6439e1e6
2 módosított fájl, 17 hozzáadás és 13 törlés
  1. 7 7
      recommend.py
  2. 10 6
      utils.py

+ 7 - 7
recommend.py

@@ -76,13 +76,13 @@ def video_recommend(mid, uid, size, app_type, algo_type, client_info):
         log_.info('mid: {}, uid: {}, bottom strategy result: {}, execute time = {}ms'.format(
             mid, uid, rank_result, (end_bottom - start_bottom) * 1000))
 
-    # ####### 视频宽高比AB实验
-    # 对内容精选进行 视频宽高比分发实验
-    if app_type == config_.APP_TYPE['LONG_VIDEO']:
-        videos = rank_result
-        rank_result = video_rank_by_w_h_rate(videos=videos)
-        log_.info('app_type: {}, mid: {}, uid: {}, rank_result: {}, execute time = {}ms'.format(
-            app_type, mid, uid, rank_result, (end_rank - start_rank) * 1000))
+    # # ####### 视频宽高比AB实验
+    # # 对内容精选进行 视频宽高比分发实验
+    # if app_type == config_.APP_TYPE['LONG_VIDEO']:
+    #     videos = rank_result
+    #     rank_result = video_rank_by_w_h_rate(videos=videos)
+    #     log_.info('app_type: {}, mid: {}, uid: {}, rank_result: {}, execute time = {}ms'.format(
+    #         app_type, mid, uid, rank_result, (end_rank - start_rank) * 1000))
 
     # ####### redis数据刷新
     # log_.info('====== update redis')

+ 10 - 6
utils.py

@@ -109,17 +109,21 @@ def update_video_w_h_rate(video_id, key_name):
     :return: None
     """
     # 获取数据
-    sql = "SELECT id, width/height w_h_rate " \
-          "FROM longvideo.wx_video " \
-          "WHERE width/height > 1 " \
-          "AND id = {};".format(video_id)
+    sql = "SELECT id, width, height, rotate FROM longvideo.wx_video WHERE id = {};".format(video_id)
     mysql_helper = MysqlHelper()
     data = mysql_helper.get_data(sql=sql)
     if len(data) == 0:
         return
     # 更新到redis
-    w_h_rate = float(data[0][1])
-    info_data = {int(video_id): w_h_rate}
+    width, height, rotate = int(data[0][1]), int(data[0][2]), int(data[0][3])
+    if rotate in (90, 270):
+        w_h_rate = height / width
+    else:
+        w_h_rate = width / height
+    if w_h_rate > 1:
+        info_data = {int(video_id): w_h_rate}
+    else:
+        return
     redis_helper = RedisHelper()
     # 写入新数据
     if len(info_data) > 0: