Browse Source

18 19 切换默认策略到基线

zhangbo 11 months ago
parent
commit
8d88969780

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

@@ -100,8 +100,6 @@ public class RecommendService {
         ab_initial_config_map.put(AppTypeEnum.VLOG.getCode(), "095");
         ab_initial_config_map.put(AppTypeEnum.LOVE_LIVE.getCode(), "144");
         ab_initial_config_map.put(AppTypeEnum.LONG_VIDEO.getCode(), "121");
-        ab_initial_config_map.put(AppTypeEnum.LAO_HAO_KAN_VIDEO.getCode(), "074");
-        ab_initial_config_map.put(AppTypeEnum.ZUI_JING_QI.getCode(), "069");
     }
 
     public RecommendResponse homepageRecommend(RecommendRequest request) {

+ 0 - 3
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/filter/strategy/AllowListStrategy.java

@@ -68,8 +68,6 @@ public class AllowListStrategy implements FilterStrategy {
         //不是新小程序 在白名单则不显示
         Set<Long> retainVideoIds = new LinkedHashSet<>();
         if (param.getAppType() != AppTypeEnum.WAN_NENG_VIDEO.getCode()
-                && param.getAppType() != AppTypeEnum.LAO_HAO_KAN_VIDEO.getCode()
-                && param.getAppType() != AppTypeEnum.ZUI_JING_QI.getCode()
                 && param.getAppType() != AppTypeEnum.H5.getCode()) {
 
             Iterator<Long> iterator = param.getVideoIds().iterator();
@@ -81,7 +79,6 @@ public class AllowListStrategy implements FilterStrategy {
                 }
             }
         } else if (param.getAppType() == AppTypeEnum.WAN_NENG_VIDEO.getCode()
-                || param.getAppType() == AppTypeEnum.ZUI_JING_QI.getCode()
                 || param.getAppType() == AppTypeEnum.H5.getCode()) {
             Iterator<Long> iterator = param.getVideoIds().iterator();
             while (iterator.hasNext()) {

+ 23 - 26
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/RankService.java

@@ -186,9 +186,23 @@ public class RankService {
                 Collections.sort(rovRecallRank, Comparator.comparingDouble(o -> -o.getSortScore()));
             }
         } else {
+            rovRecallRank.addAll(extractAndSort(param, RegionRealtimeRecallStrategyV1.PUSH_FORM));
             rovRecallRank.addAll(extractAndSort(param, SimHotVideoRecallStrategy.PUSH_FORM));
             rovRecallRank.addAll(extractAndSort(param, ReturnVideoRecallStrategy.PUSH_FORM));
             removeDuplicate(rovRecallRank);
+
+            // 融合排序
+            List<String> videoIdKeys = rovRecallRank.stream()
+                    .map(t -> param.getRankKeyPrefix() + t.getVideoId())
+                    .collect(Collectors.toList());
+            List<String> videoScores = redisTemplate.opsForValue().multiGet(videoIdKeys);
+            if (CollectionUtils.isNotEmpty(videoScores)
+                    && videoScores.size() == rovRecallRank.size()) {
+                for (int i = 0; i < videoScores.size(); i++) {
+                    rovRecallRank.get(i).setSortScore(NumberUtils.toDouble(videoScores.get(i), 0.0));
+                }
+                rovRecallRank.sort(Comparator.comparingDouble(o -> -o.getSortScore()));
+            }
         }
         return rovRecallRank;
     }
@@ -267,23 +281,11 @@ public class RankService {
     }
 
     public List<Video> mergeAndRankFlowPoolRecall(RankParam param) {
-        if (param.getAppType() == AppTypeEnum.LAO_HAO_KAN_VIDEO.getCode()
-                || param.getAppType() == AppTypeEnum.ZUI_JING_QI.getCode()) {
-            if (param.getAbCode().equals("60054")
-                    || param.getAbCode().equals("60068")
-                    || param.getAbCode().equals("60081")
-                    || param.getAbCode().equals("60084")) {
-                return extractAndSort(param, FlowPoolConstants.QUICK_PUSH_FORM);
-            } else {
-                return Collections.emptyList();
-            }
+        List<Video> quickFlowPoolVideos = extractAndSort(param, FlowPoolConstants.QUICK_PUSH_FORM);
+        if (CollectionUtils.isNotEmpty(quickFlowPoolVideos)) {
+            return quickFlowPoolVideos;
         } else {
-            List<Video> quickFlowPoolVideos = extractAndSort(param, FlowPoolConstants.QUICK_PUSH_FORM);
-            if (CollectionUtils.isNotEmpty(quickFlowPoolVideos)) {
-                return quickFlowPoolVideos;
-            } else {
-                return extractAndSort(param, FlowPoolConstants.PUSH_FORM);
-            }
+            return extractAndSort(param, FlowPoolConstants.PUSH_FORM);
         }
     }
 
@@ -307,17 +309,12 @@ public class RankService {
     }
 
     public double getFlowPoolP(RankParam param) {
-        if (param.getAppType() == AppTypeEnum.LAO_HAO_KAN_VIDEO.getCode()
-                || param.getAppType() == AppTypeEnum.ZUI_JING_QI.getCode()) {
-            return param.getFlowPoolP();
+        List<Video> quickFlowPoolVideos = extractAndSort(param, FlowPoolConstants.QUICK_PUSH_FORM);
+        if (CollectionUtils.isNotEmpty(quickFlowPoolVideos)) {
+            String quick_flow_pool_P = redisTemplate.opsForValue().get("flow:pool:quick:distribute:rate:3");
+            return NumberUtils.toDouble(quick_flow_pool_P, 0);
         } else {
-            List<Video> quickFlowPoolVideos = extractAndSort(param, FlowPoolConstants.QUICK_PUSH_FORM);
-            if (CollectionUtils.isNotEmpty(quickFlowPoolVideos)) {
-                String quick_flow_pool_P = redisTemplate.opsForValue().get("flow:pool:quick:distribute:rate:3");
-                return NumberUtils.toDouble(quick_flow_pool_P, 0);
-            } else {
-                return param.getFlowPoolP();
-            }
+            return param.getFlowPoolP();
         }
     }
 

+ 78 - 83
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallService.java

@@ -97,11 +97,8 @@ public class RecallService implements ApplicationContextAware {
         boolean isInBlacklist = CollectionUtils.isNotEmpty(blacklistAppTypeSet) && blacklistAppTypeSet.contains(param.getAppType());
 
         String abCode = param.getAbCode();
-        //1:通过“产品”控制“召回子策略”
-        if (param.getAppType() == AppTypeEnum.LAO_HAO_KAN_VIDEO.getCode()
-                || param.getAppType() == AppTypeEnum.ZUI_JING_QI.getCode()) {
-            strategies.addAll(getRegionRecallStrategy(param));
-        } else if (param.getAppType() == AppTypeEnum.PIAO_QUAN_MEIHAO_ZHUFU.getCode() && Objects.equals(param.getCategoryId(), 100)) {
+        //1:通过“产品”控制“召回子策略”. 票圈美好祝福与内部tab只走祝福召回。APP只走固定列表。
+        if (param.getAppType() == AppTypeEnum.PIAO_QUAN_MEIHAO_ZHUFU.getCode() && Objects.equals(param.getCategoryId(), 100)) {
             strategies.add(strategyMap.get(BlessRecallStrategy.class.getSimpleName()));
             return strategies;
         } else if (param.getAppType() == AppTypeEnum.APP_SPEED.getCode()) {
@@ -175,6 +172,7 @@ public class RecallService implements ApplicationContextAware {
                     strategies.add(strategyMap.get(TitleTagRecallStrategyV1.class.getSimpleName()));
                     strategies.addAll(getRegionRecallStrategy(param));
                 default:
+                    strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV1.class.getSimpleName()));
                     strategies.addAll(getRegionRecallStrategy(param));
             }
             // 命中用户黑名单不走流量池
@@ -244,84 +242,81 @@ public class RecallService implements ApplicationContextAware {
         }
 
         //3:通过“abcode”控制“召回子策略”
-
-        if (abCode == null) {
-            // todo 做兜底吗?
-        } else {
-            switch (abCode) {
-                case "60096":
-                    strategies.add(strategyMap.get(RegionHWithoutDupRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                    break;
-                case "60111": // 561
-                case "60068":
-                case "60092":
-                case "60094":
-                case "60097": // 523
-                case "60098": // 533
-                case "60101": // 排序str实验
-                case "60102": // 通过更改param中的配置实现使用不同数据源 data66 rule68 + 无排序模块
-                case "60103": // 增加地域1小时扩量,通过配置实现
-                case "60120": // 576
-                    strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                    break;
-                case "60112": // 562
-                    strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV5Hand.class.getSimpleName()));
-                    break;
-                case "60121": // 536
-                case "60122": // 537
-                case "60124": // 546
-                case "60125": // 547
-                case "60123": // 541
-                case "60126": // 548
-                case "60105": // 551
-                case "60106": // 552
-                case "60107": // 553
-                case "60116": // 566
-                case "60119": // 569
-                    strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
-                    break;
-                case "60113": // 563
-                case "60114": // 564
-                case "60115": // 565
-                case "60117": // 567
-                case "60118": // 568
-                case "60150": // 645
-                    if (!hitUserBlacklist || !isInBlacklist) {
-                        strategies.add(strategyMap.get(FlowPoolLastDayTopRecallStrategy.class.getSimpleName()));
-                    }
-                    strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
-                    break;
-                case "60104": // 去掉sim的对比实验
-                    strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                    break;
-                case "60110": // 新内容的召回(流量池的Top内容)
-                    strategies.add(strategyMap.get(TopGoodPerformanceVideoRecallStrategy.class.getSimpleName()));
-                    if (!hitUserBlacklist || !isInBlacklist) {
-                        strategies.add(strategyMap.get(FlowPoolLastDayTopRecallStrategy.class.getSimpleName()));
-                    }
-                    strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                    break;
-                case "60130":
-                case "60131":
-                case "60132":
-                    strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
-                    strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
-                    break;
-                default:
-                    // todo 做兜底吗?
-                    break;
-            }
+        switch (abCode) {
+            case "60096":
+                strategies.add(strategyMap.get(RegionHWithoutDupRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                break;
+            case "60111": // 561
+            case "60068":
+            case "60092":
+            case "60094":
+            case "60097": // 523
+            case "60098": // 533
+            case "60101": // 排序str实验
+            case "60102": // 通过更改param中的配置实现使用不同数据源 data66 rule68 + 无排序模块
+            case "60103": // 增加地域1小时扩量,通过配置实现
+            case "60120": // 576
+                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                break;
+            case "60112": // 562
+                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(RegionRealtimeRecallStrategyV5Hand.class.getSimpleName()));
+                break;
+            case "60121": // 536
+            case "60122": // 537
+            case "60124": // 546
+            case "60125": // 547
+            case "60123": // 541
+            case "60126": // 548
+            case "60105": // 551
+            case "60106": // 552
+            case "60107": // 553
+            case "60116": // 566
+            case "60119": // 569
+                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
+                break;
+            case "60113": // 563
+            case "60114": // 564
+            case "60115": // 565
+            case "60117": // 567
+            case "60118": // 568
+            case "60150": // 645
+                if (!hitUserBlacklist || !isInBlacklist) {
+                    strategies.add(strategyMap.get(FlowPoolLastDayTopRecallStrategy.class.getSimpleName()));
+                }
+                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
+                break;
+            case "60104": // 去掉sim的对比实验
+                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                break;
+            case "60110": // 新内容的召回(流量池的Top内容)
+                strategies.add(strategyMap.get(TopGoodPerformanceVideoRecallStrategy.class.getSimpleName()));
+                if (!hitUserBlacklist || !isInBlacklist) {
+                    strategies.add(strategyMap.get(FlowPoolLastDayTopRecallStrategy.class.getSimpleName()));
+                }
+                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                break;
+            case "60130":
+            case "60131":
+            case "60132":
+                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
+                break;
+            default:
+                strategies.add(strategyMap.get(SimHotVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(ReturnVideoRecallStrategy.class.getSimpleName()));
+                strategies.add(strategyMap.get(FestivalRecallStrategyV1.class.getSimpleName()));
+                break;
         }
 
         return strategies;