Browse Source

info: distribute count filter

丁云鹏 3 months ago
parent
commit
f7a6df330c

+ 0 - 34
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/filter/FlowPoolWithLevelFilterService.java

@@ -18,43 +18,9 @@ import java.util.stream.Collectors;
 @Service
 @Slf4j
 public class FlowPoolWithLevelFilterService extends AbstractFilterService {
-    @Autowired
-    private FlowPoolService flowPoolService;
 
     public FilterResult filter(FilterParam param) {
-        log.info("distribute count filter param1:{}", JSONUtils.toJson(param));
         List<Long> videoIds = viewFilter(param);
-        log.info("distribute count filter param2:{}", JSONUtils.toJson(param));
-        videoIds = filterDistributeCountAndDel(param, videoIds);
-
         return new FilterResult(videoIds);
     }
-
-    private List<Long> filterDistributeCountAndDel(FilterParam param, List<Long> videoIds) {
-        log.info("distribute count filter param:{}", JSONUtils.toJson(param));
-        if (CollectionUtils.isEmpty(videoIds)
-                || MapUtils.isEmpty(param.getFlowPoolMap())) {
-            return videoIds;
-        }
-        Map<Long, String> flowPoolMap = videoIds.stream()
-                .filter(v -> param.getFlowPoolMap().containsKey(v)
-                        && StringUtils.isNotBlank(param.getFlowPoolMap().get(v)))
-                .collect(Collectors.toMap(
-                        v -> v,
-                        v -> param.getFlowPoolMap().get(v)));
-
-        Map<Long, Integer> distributeCountMap;
-        distributeCountMap = flowPoolService.getDistributeCountWithLevel(flowPoolMap);
-
-        List<Long> remainVideoIds = new ArrayList<>();
-        for (Long videoId : videoIds) {
-            if (distributeCountMap.get(videoId) != null
-                    && distributeCountMap.get(videoId) > 0) {
-                remainVideoIds.add(videoId);
-            }
-        }
-        log.info("distribute count filter size before:{} after:{} equals:{}", videoIds.size(), remainVideoIds.size(),
-                videoIds.size() == remainVideoIds.size());
-        return remainVideoIds;
-    }
 }

+ 0 - 39
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/flowpool/FlowPoolService.java

@@ -45,28 +45,6 @@ public class FlowPoolService {
             SHORT_VIDEO.getCode(), H5.getCode(), APP_SPEED.getCode(), WAN_NENG_VIDEO.getCode(),
             LAO_HAO_KAN_VIDEO.getCode(), ZUI_JING_QI.getCode(), PIAO_QUAN_VIDEO_PLUS.getCode(), JOURNEY.getCode()};
 
-
-    public Map<Long, Integer> getDistributeCountWithLevel(Map<Long, String> videoFlowPoolMap) {
-        if (MapUtils.isEmpty(videoFlowPoolMap)) {
-            return Collections.emptyMap();
-        }
-
-        Map<Long, Integer> result = getDistributeCount(videoFlowPoolMap);
-
-
-        // 处理脏数据:分发数<0
-        Map<Long, String> dirties = videoFlowPoolMap.entrySet().stream()
-                .filter(e -> result.get(e.getKey()) <= 0)
-                .collect(Collectors.toMap(
-                        e -> e.getKey(),
-                        e -> e.getValue()
-                ));
-        log.info("dirties size:{}", dirties.size());
-        asyncDelDistributeCountWithLevel(dirties);
-
-        return result;
-    }
-
     public void updateDistributeCountWithLevel(List<Video> videos) {
         if (CollectionUtils.isEmpty(videos)) {
             return;
@@ -92,23 +70,6 @@ public class FlowPoolService {
 
     }
 
-    private Map<Long, Integer> getDistributeCount(Map<Long, String> videoFlowPoolMap) {
-        // 为了保证有序
-        List<Map.Entry<Long, String>> entries = videoFlowPoolMap.entrySet().stream()
-                .sorted(Comparator.comparingLong(e -> e.getKey()))
-                .collect(Collectors.toList());
-
-        List<String> keys = entries.stream()
-                .map(v -> String.format(localDistributeCountFormat, v.getKey(), v.getValue()))
-                .collect(Collectors.toList());
-        List<String> counts = redisTemplate.opsForValue().multiGet(keys);
-        Map<Long, Integer> result = new HashMap<>();
-        for (int i = 0; i < entries.size(); i++) {
-            result.put(entries.get(i).getKey(), NumberUtils.toInt(counts.get(i), 0));
-        }
-        return result;
-    }
-
     private Map<Long, String> updateDistributeCount(List<Video> videos) {
         // TODO 异步更新
         Map<Long, String> removeMap = new HashMap<>();