Browse Source

cold start

丁云鹏 11 months ago
parent
commit
6c27e4951a

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

@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
 @Component
 public class ViewMultiplierStrategy implements ScoreStrategy {
 
-    @Resource(name="programDataJdbcTemplate")
+    @Resource(name = "programDataJdbcTemplate")
     NamedParameterJdbcTemplate programDataJdbcTemplate;
     private JSONObject jsonObject;
 
@@ -52,7 +52,7 @@ public class ViewMultiplierStrategy implements ScoreStrategy {
             if (Objects.nonNull(articleDTO) && Objects.nonNull(datastatDTO)) {
                 double avgReadCount = getAvgReadCount(articleDTO.getAccountId(), articleDTO.getItemIndex());
                 Integer readCount = datastatDTO.getReadCount();
-                score.setScore(NormalizationUtils.min(readCount / avgReadCount - 1));
+                score.setScore(NormalizationUtils.min(Math.max(readCount, 0) / avgReadCount - 1));
             } else {
                 score.setScore(-1.0);
             }