Forráskód Böngészése

阅读均值表查询修改 增加日志

wangyunpeng 10 hónapja
szülő
commit
fb98bb73e3
13 módosított fájl, 62 hozzáadás és 9 törlés
  1. 8 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV5Strategy.java
  2. 2 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/CategoryStrategy.java
  3. 4 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/ContentPoolStrategy.java
  4. 2 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/FlowCtlDecreaseStrategy.java
  5. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/HisFissionAvgReadRateRateStrategy.java
  6. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/HisFissionAvgReadSumRateStrategy.java
  7. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/HisFissionFansRateRateStrategy.java
  8. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/HisFissionFansSumRateStrategy.java
  9. 2 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/PublishTimesStrategy.java
  10. 4 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/SimilarityStrategy.java
  11. 24 5
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/ViewCountRateStrategy.java
  12. 4 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/ViewCountStrategy.java
  13. 4 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/ViewMultiplierStrategy.java

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

@@ -89,6 +89,13 @@ public class RankV5Strategy implements RankStrategy {
         List<Content> pool1 = contentMap.get(contentPools[0]);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
+            result.add(pool1.get(1));
+            result.add(pool1.get(2));
+            result.add(pool1.get(3));
+            result.add(pool1.get(4));
+            result.add(pool1.get(5));
+            result.add(pool1.get(6));
+            result.add(pool1.get(7));
         } else {
             // 替补
             AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(1);
@@ -128,7 +135,7 @@ public class RankV5Strategy implements RankStrategy {
 
         // 3-8
         List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool)) {
+        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
             result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
         }
 

+ 2 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/CategoryStrategy.java

@@ -31,6 +31,7 @@ public class CategoryStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
         List<Score> scores = new ArrayList<>();
         if (CollectionUtils.isEmpty(param.getContents())) {
             return scores;
@@ -60,7 +61,7 @@ public class CategoryStrategy implements ScoreStrategy {
             }
             scores.add(score);
         }
-
+        log.info("CategoryStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 

+ 4 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/ContentPoolStrategy.java

@@ -6,6 +6,7 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
 import com.tzld.longarticle.recommend.server.service.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.NormalizationUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
@@ -17,6 +18,7 @@ import java.util.Map;
  * @author dyp
  */
 @Component
+@Slf4j
 public class ContentPoolStrategy implements ScoreStrategy {
 
     @ApolloJsonValue("${contentPoolScore:{}}")
@@ -24,6 +26,7 @@ public class ContentPoolStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
 
         if (CollectionUtils.isEmpty(param.getContents())) {
             return Collections.emptyList();
@@ -44,6 +47,7 @@ public class ContentPoolStrategy implements ScoreStrategy {
             score.setStrategy(this);
             return score;
         });
+        log.info("ContentPoolStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 

+ 2 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/FlowCtlDecreaseStrategy.java

@@ -42,6 +42,7 @@ public class FlowCtlDecreaseStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
         List<Score> scores = new ArrayList<>();
         if (CollectionUtils.isEmpty(param.getContents())) {
             return scores;
@@ -61,7 +62,7 @@ public class FlowCtlDecreaseStrategy implements ScoreStrategy {
                 scores.add(score);
             }
         }
-
+        log.info("FlowCtlDecreaseStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/HisFissionAvgReadRateRateStrategy.java

@@ -22,6 +22,7 @@ public class HisFissionAvgReadRateRateStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
         List<Score> scores = new ArrayList<>();
         for (Content content : param.getContents()) {
             if (CollectionUtils.isEmpty(content.getHisPublishArticleList())) {
@@ -33,6 +34,7 @@ public class HisFissionAvgReadRateRateStrategy implements ScoreStrategy {
             score.setScore(content.getT0FissionByReadAvgMean());
             scores.add(score);
         }
+        log.info("HisFissionAvgReadRateRateStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 }

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/HisFissionAvgReadSumRateStrategy.java

@@ -22,6 +22,7 @@ public class HisFissionAvgReadSumRateStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
         List<Score> scores = new ArrayList<>();
         for (Content content : param.getContents()) {
             if (CollectionUtils.isEmpty(content.getHisPublishArticleList())) {
@@ -33,6 +34,7 @@ public class HisFissionAvgReadSumRateStrategy implements ScoreStrategy {
             score.setScore(content.getT0FissionByReadAvgSumAvg());
             scores.add(score);
         }
+        log.info("HisFissionAvgReadSumRateStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 }

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/HisFissionFansRateRateStrategy.java

@@ -22,6 +22,7 @@ public class HisFissionFansRateRateStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
         List<Score> scores = new ArrayList<>();
         for (Content content : param.getContents()) {
             if (CollectionUtils.isEmpty(content.getHisPublishArticleList())) {
@@ -33,6 +34,7 @@ public class HisFissionFansRateRateStrategy implements ScoreStrategy {
             score.setScore(content.getT0FissionByFansMean());
             scores.add(score);
         }
+        log.info("HisFissionFansRateRateStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 }

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/HisFissionFansSumRateStrategy.java

@@ -22,6 +22,7 @@ public class HisFissionFansSumRateStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
         List<Score> scores = new ArrayList<>();
         for (Content content : param.getContents()) {
             if (CollectionUtils.isEmpty(content.getHisPublishArticleList())) {
@@ -33,6 +34,7 @@ public class HisFissionFansSumRateStrategy implements ScoreStrategy {
             score.setScore(content.getT0FissionByFansSumAvg());
             scores.add(score);
         }
+        log.info("HisFissionFansSumRateStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 }

+ 2 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/PublishTimesStrategy.java

@@ -39,6 +39,7 @@ public class PublishTimesStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
         List<Score> scores = new ArrayList<>();
         if (CollectionUtils.isEmpty(param.getContents())) {
             return scores;
@@ -90,7 +91,7 @@ public class PublishTimesStrategy implements ScoreStrategy {
             }
             scores.add(score);
         }
-
+        log.info("PublishTimesStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 

+ 4 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/SimilarityStrategy.java

@@ -5,6 +5,7 @@ import com.tzld.longarticle.recommend.server.service.score.Score;
 import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
 import com.tzld.longarticle.recommend.server.service.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
@@ -17,6 +18,7 @@ import java.util.Map;
  * @author dyp
  */
 @Component
+@Slf4j
 public class SimilarityStrategy implements ScoreStrategy {
 
     @Autowired
@@ -24,6 +26,7 @@ public class SimilarityStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
 
         if (CollectionUtils.isEmpty(param.getContents())) {
             return Collections.emptyList();
@@ -46,6 +49,7 @@ public class SimilarityStrategy implements ScoreStrategy {
             score.setStrategy(this);
             return score;
         });
+        log.info("SimilarityStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 

+ 24 - 5
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/ViewCountRateStrategy.java

@@ -2,6 +2,8 @@ package com.tzld.longarticle.recommend.server.service.score.strategy;
 
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.model.ContentHisPublishArticle;
+import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
+import com.tzld.longarticle.recommend.server.repository.entity.crawler.AccountAvgInfo;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.AccountIndexAvgViewCountService;
 import com.tzld.longarticle.recommend.server.service.score.Score;
@@ -12,7 +14,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 @Component
 @Slf4j
@@ -21,19 +27,31 @@ public class ViewCountRateStrategy implements ScoreStrategy {
     @Autowired
     AccountIndexAvgViewCountService accountIndexAvgViewCountService;
     @Autowired
-    private AccountContentPoolConfigService accountContentPoolConfigService;
+    AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    AccountAvgInfoRepository accountAvgInfoRepository;
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
         List<Score> scores = new ArrayList<>();
+        String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
+        List<AccountAvgInfo> avgInfoList = accountAvgInfoRepository.getAllByGhIdEqualsAndStatusEquals(param.getGhId(), 1);
+        Map<Integer, Double> avgInfoMap = avgInfoList.stream().collect(Collectors.toMap(o -> Integer.valueOf(o.getPosition()), AccountAvgInfo::getReadAvg));
+        double avgViewCountFirst = avgInfoMap.get(1);
         for (Content content : param.getContents()) {
-            String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
             for (int i = 0; i < contentPools.length; i++) {
                 if (!contentPools[i].equals(content.getContentPoolType())) {
                     continue;
                 }
-                double avgViewCountPos = accountIndexAvgViewCountService.getAvgReadCountByDB(param.getGhId(), i + 1);
-                double avgViewCountFirst = accountIndexAvgViewCountService.getAvgReadCountByDB(param.getGhId(), 1);
+                double avgViewCountPos;
+                if (avgInfoMap.containsKey(i + 1)) {
+                    avgViewCountPos = avgInfoMap.get(i + 1);
+                } else if (avgInfoMap.containsKey(4)) {
+                    avgViewCountPos = avgInfoMap.get(4);
+                } else {
+                    avgViewCountPos = avgInfoMap.get(1);
+                }
                 double showViewCountSum = 0D;
                 double avgViewCountSum = 0D;
                 double showViewCountSumFirst = 0D;
@@ -88,6 +106,7 @@ public class ViewCountRateStrategy implements ScoreStrategy {
                 break;
             }
         }
+        log.info("ViewCountRateStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 }

+ 4 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/ViewCountStrategy.java

@@ -5,6 +5,7 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
 import com.tzld.longarticle.recommend.server.service.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.NormalizationUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
@@ -15,10 +16,12 @@ import java.util.List;
  * @author dyp
  */
 @Component
+@Slf4j
 public class ViewCountStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
 
         if (CollectionUtils.isEmpty(param.getContents())) {
             return Collections.emptyList();
@@ -41,6 +44,7 @@ public class ViewCountStrategy implements ScoreStrategy {
             score.setStrategy(this);
             return score;
         });
+        log.info("ViewCountStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }
 

+ 4 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/ViewMultiplierStrategy.java

@@ -11,6 +11,7 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
 import com.tzld.longarticle.recommend.server.service.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.NormalizationUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
@@ -22,6 +23,7 @@ import java.util.stream.Collectors;
  * @author dyp
  */
 @Component
+@Slf4j
 public class ViewMultiplierStrategy implements ScoreStrategy {
 
     @Autowired
@@ -33,6 +35,7 @@ public class ViewMultiplierStrategy implements ScoreStrategy {
 
     @Override
     public List<Score> score(ScoreParam param) {
+        long start = System.currentTimeMillis();
 
         if (CollectionUtils.isEmpty(param.getContents())) {
             return Collections.emptyList();
@@ -57,6 +60,7 @@ public class ViewMultiplierStrategy implements ScoreStrategy {
             score.setStrategy(this);
             return score;
         });
+        log.info("ViewMultiplierStrategy cost:{}", System.currentTimeMillis() - start);
         return scores;
     }