Просмотр исходного кода

Merge branch 'feature_20240605_zhaohaipeng_ad_filter_exp' into test

zhaohaipeng 1 год назад
Родитель
Сommit
f3978a0e04

+ 11 - 10
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/VideoAdThompsonScorerV2.java

@@ -18,8 +18,6 @@ import org.springframework.stereotype.Component;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import static com.tzld.piaoquan.ad.engine.commons.score.model.ThompsonSamplingModel.alpha;
-
 @Component
 public class VideoAdThompsonScorerV2 {
     Logger log = LoggerFactory.getLogger(VideoAdThompsonScorerV2.class);
@@ -561,23 +559,26 @@ public class VideoAdThompsonScorerV2 {
     public List<AdRankItem> thompsonScorerByExp672(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
         String cidRedisKey = exp672Param.getOrDefault("cidActionRedisKey", redisCidActionKeyV1);
         String vidCidRedisKey = exp672Param.getOrDefault("vidCidActionRedisKey", redisCidVidActionKeyV1);
-        double viewThreshold = Double.parseDouble(exp672Param.getOrDefault("viewThreshold", "7000"));
 
 
         Map<Long, CreativeStatistic> paramCidRedisCache = this.batchFindCreativeRedisCache(cidRedisKey, adIdList);
         Map<Long, CreativeStatistic> paramVidCidRedisCache = this.batchFindCreativeRedisCache(vidCidRedisKey, adIdList);
 
-        Map<Long, CreativeStatistic> defaultCidCache = this.batchFindCreativeRedisCache(redisCidActionKeyV1, adIdList);
-        Map<Long, CreativeStatistic> defaultVidCidCache = this.batchFindCreativeRedisCache(redisCidVidActionKeyV1, adIdList);
+        // 兜底逻辑
+        if (MapUtils.isEmpty(paramCidRedisCache) && MapUtils.isEmpty(paramVidCidRedisCache)) {
 
-        for (AdPlatformCreativeDTO dto : adIdList) {
-            Long cid = dto.getCreativeId();
-            paramCidRedisCache.putIfAbsent(cid, defaultCidCache.getOrDefault(cid, new CreativeStatistic()));
-            paramVidCidRedisCache.putIfAbsent(cid, defaultVidCidCache.getOrDefault(cid, new CreativeStatistic()));
+            Map<Long, CreativeStatistic> defaultCidCache = this.batchFindCreativeRedisCache(redisCidActionKeyV1, adIdList);
+            Map<Long, CreativeStatistic> defaultVidCidCache = this.batchFindCreativeRedisCache(redisCidVidActionKeyV1, adIdList);
+
+            for (AdPlatformCreativeDTO dto : adIdList) {
+                Long cid = dto.getCreativeId();
+                paramCidRedisCache.putIfAbsent(cid, defaultCidCache.getOrDefault(cid, new CreativeStatistic()));
+                paramVidCidRedisCache.putIfAbsent(cid, defaultVidCidCache.getOrDefault(cid, new CreativeStatistic()));
+            }
         }
 
+        double viewThreshold = Double.parseDouble(exp672Param.getOrDefault("viewThreshold", "7000"));
         List<AdRankItem> result = new ArrayList<>(adIdList.size());
-
         for (AdPlatformCreativeDTO dto : adIdList) {
             Map<String, Object> ext = new HashMap<>();
             double score = 0.0;