wangyunpeng 9 月之前
父節點
當前提交
79a7769e93

+ 16 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/RankService.java

@@ -1,16 +1,17 @@
 package com.tzld.longarticle.recommend.server.service.rank;
 
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
+import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
-import com.tzld.longarticle.recommend.server.service.filter.strategy.BadStrategy;
-import com.tzld.longarticle.recommend.server.service.filter.strategy.HistoryTitleForFwhColdStartStrategy;
-import com.tzld.longarticle.recommend.server.service.filter.strategy.HistoryTitleStrategy;
-import com.tzld.longarticle.recommend.server.service.filter.strategy.SensitiveStrategy;
 import com.tzld.longarticle.recommend.server.service.rank.strategy.FwhColdStartRankStrategy;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 import static com.tzld.longarticle.recommend.server.service.SceneConstants.FWH_COLD_START;
 
 /**
@@ -37,4 +38,15 @@ public class RankService {
 
     }
 
+    public static void printSortLog(String strategy, String accountName, List<Content> contentList) {
+        JSONArray jsonArray = new JSONArray();
+        for (Content content : contentList) {
+            JSONObject obj = new JSONObject();
+            obj.put("title", content.getTitle());
+            obj.put("score", content.getScore());
+            obj.put("scoreMap", content.getScoreMap());
+            jsonArray.add(obj);
+        }
+        log.info("{} 账号名称 {} 头条评分结果 {}", strategy, accountName, JSONObject.toJSONString(jsonArray));
+    }
 }

+ 3 - 6
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV11Strategy.java

@@ -1,14 +1,11 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.alibaba.fastjson.JSONObject;
+import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.StrategyIndexScoreWeightService;
-import com.tzld.longarticle.recommend.server.service.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.rank.*;
 import com.tzld.longarticle.recommend.server.service.score.AccountIndexReplacePoolConfig;
 import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
@@ -113,7 +110,7 @@ public class RankV11Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        log.info("RankV11Strategy 头条评分结果 {}", JSONObject.toJSONString(pool1));
+        RankService.printSortLog(RankStrategyEnum.ArticleRankV11.getStrategy(), param.getAccountName(), pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {

+ 3 - 6
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV12Strategy.java

@@ -1,14 +1,11 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.alibaba.fastjson.JSONObject;
+import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.StrategyIndexScoreWeightService;
-import com.tzld.longarticle.recommend.server.service.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.rank.*;
 import com.tzld.longarticle.recommend.server.service.score.AccountIndexReplacePoolConfig;
 import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
@@ -113,7 +110,7 @@ public class RankV12Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        log.info("RankV12Strategy 头条评分结果 {}", JSONObject.toJSONString(pool1));
+        RankService.printSortLog(RankStrategyEnum.ArticleRankV12.getStrategy(), param.getAccountName(), pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {

+ 5 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV5Strategy.java

@@ -1,12 +1,10 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.rank.*;
 import com.tzld.longarticle.recommend.server.service.score.AccountIndexReplacePoolConfig;
 import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
@@ -94,6 +92,9 @@ public class RankV5Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if ("gh_ac43e43b253b".equals(param.getGhId())) {
+            RankService.printSortLog(RankStrategyEnum.ArticleRankV5.getStrategy(), param.getAccountName(), pool1);
+        }
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {