Kaynağa Gözat

homepage recommend

丁云鹏 1 yıl önce
ebeveyn
işleme
ab4e911d19

+ 10 - 2
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/RecommendService.java

@@ -323,7 +323,7 @@ public class RecommendService {
                     data.setInFlowPool(true);
                 } else {
                     String isIn_flow_pool_key =
-                            String.format("flow:pool:video:ids:%s:3", param.getAppType());
+                            String.format("flow:pool:video:ids:%s", param.getAppType());
                     String flow_pool_key =
                             String.format("flow:pool:video:%s:%s", param.getAppType(), videoId);
                     if (redisTemplate.opsForSet().isMember(isIn_flow_pool_key, String.valueOf(videoId))) {
@@ -338,7 +338,7 @@ public class RecommendService {
     }
 
     private void updateCache(RecommendRequest request, RecommendParam param, List<Video> videos) {
-        if (StringUtils.isNotBlank(request.getMid())
+        if (StringUtils.isBlank(request.getMid())
                 || CollectionUtils.isEmpty(videos)) {
             return;
         }
@@ -362,6 +362,10 @@ public class RecommendService {
                 .collect(Collectors.toList());
 
 
+        if (CollectionUtils.isEmpty(flowPoolVideos)) {
+            return;
+        }
+
         switch (param.getFlowPoolAbtestGroup()) {
             case FlowPoolConstants.EXPERIMENTAL_FLOW_SET_LEVEL:
                 flowPoolService.updateDistributeCountWithLevel(flowPoolVideos);
@@ -383,6 +387,7 @@ public class RecommendService {
                 redisTemplate.opsForValue().set(String.format(RegionHRecallStrategy.LAST_VIDEO_KEY_FORMAT,
                                 request.getAppType(), request.getMid()), String.valueOf(videos.get(i).getVideoId()),
                         24, TimeUnit.HOURS);
+                break;
             }
         }
 
@@ -392,6 +397,7 @@ public class RecommendService {
                 redisTemplate.opsForValue().set(String.format(Region24HRecallStrategy.LAST_VIDEO_KEY_FORMAT,
                                 request.getAppType(), request.getMid()), String.valueOf(videos.get(i).getVideoId()),
                         24, TimeUnit.HOURS);
+                break;
             }
         }
 
@@ -401,6 +407,7 @@ public class RecommendService {
                 redisTemplate.opsForValue().set(String.format(RegionRelative24HRecallStrategy.LAST_VIDEO_KEY_FORMAT,
                                 request.getAppType(), request.getMid()), String.valueOf(videos.get(i).getVideoId()),
                         24, TimeUnit.HOURS);
+                break;
             }
         }
 
@@ -410,6 +417,7 @@ public class RecommendService {
                 redisTemplate.opsForValue().set(String.format(RegionRelative24HDupRecallStrategy.LAST_VIDEO_KEY_FORMAT,
                                 request.getAppType(), request.getMid()), String.valueOf(videos.get(i).getVideoId()),
                         24, TimeUnit.HOURS);
+                break;
             }
         }
     }

+ 2 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/AbstractVideoRecallStrategy.java

@@ -8,6 +8,7 @@ import com.tzld.piaoquan.recommend.server.service.filter.VideoFilterService;
 import com.tzld.piaoquan.recommend.server.service.recall.FilterParamFactory;
 import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
 import com.tzld.piaoquan.recommend.server.service.recall.RecallStrategy;
+import com.tzld.piaoquan.recommend.server.util.JSONUtils;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -39,6 +40,7 @@ public abstract class AbstractVideoRecallStrategy implements RecallStrategy {
         String recall_key = recallKey(param);
         // [[16687915, 0.5], [16528093, 0.5]]
         String value = redisTemplate.opsForValue().get(recall_key);
+        log.info("recall recall_key={}, value={}", recall_key, JSONUtils.toJson(value));
         if (StringUtils.isBlank(value)) {
             return null;
         }

+ 2 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/ReturnVideoRecallStrategy.java

@@ -1,10 +1,12 @@
 package com.tzld.piaoquan.recommend.server.service.recall.strategy;
 
 import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
+import org.springframework.stereotype.Service;
 
 /**
  * @author dyp
  */
+@Service
 public class ReturnVideoRecallStrategy extends AbstractVideoRecallStrategy {
     public static final String PUSH_FORM = "return_video_recall";
 

+ 2 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/SimHotVideoRecallStrategy.java

@@ -1,10 +1,12 @@
 package com.tzld.piaoquan.recommend.server.service.recall.strategy;
 
 import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
+import org.springframework.stereotype.Service;
 
 /**
  * @author dyp
  */
+@Service
 public class SimHotVideoRecallStrategy extends AbstractVideoRecallStrategy {
 
     public static final String PUSH_FORM = "sim_hot_vid_recall";