Przeglądaj źródła

Merge branch 'wyp/1012-hisContentFilter' of Server/long-article-recommend into master

wangyunpeng 9 miesięcy temu
rodzic
commit
ee16c73641

+ 8 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/ScoreStrategy.java

@@ -1,6 +1,8 @@
 package com.tzld.longarticle.recommend.server.service.score;
 
 
+import com.tzld.longarticle.recommend.server.util.DateUtils;
+
 import java.util.List;
 
 /**
@@ -8,4 +10,10 @@ import java.util.List;
  */
 public interface ScoreStrategy {
     List<Score> score(ScoreParam param);
+
+    public default boolean hisContentLateFilter(Long publishTime) {
+        // 过滤掉发布时间晚于19点数据
+        int publishHour = DateUtils.getHourByTimestamp(publishTime);
+        return publishHour >= 19;
+    }
 }

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

@@ -2,14 +2,13 @@ package com.tzld.longarticle.recommend.server.service.score.strategy;
 
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.dto.ContentHisPublishArticle;
-import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo;
+import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
 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;
 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.DateUtils;
 import com.tzld.longarticle.recommend.server.util.MathUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -69,9 +68,8 @@ public class ViewCountRateCorrelationStrategy implements ScoreStrategy {
                 double avgViewCountSumSecond = 0D;
                 double maxAvgViewCount = 0D;
                 for (ContentHisPublishArticle hisItem : content.getHisPublishArticleList()) {
-                    // 过滤掉发布时间晚于20点数据
-                    int publishHour = DateUtils.getHourByTimestamp(hisItem.getUpdateTime());
-                    if (publishHour >= 19) {
+                    // 过滤掉发布时间晚于19点数据
+                    if (hisContentLateFilter(hisItem.getUpdateTime())) {
                         continue;
                     }
                     if (hisItem.isInnerAccount() && Objects.nonNull(hisItem.getViewCount())

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

@@ -2,14 +2,13 @@ package com.tzld.longarticle.recommend.server.service.score.strategy;
 
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.dto.ContentHisPublishArticle;
-import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo;
+import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
 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;
 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.DateUtils;
 import com.tzld.longarticle.recommend.server.util.MathUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -69,9 +68,8 @@ public class ViewCountRateStrategy implements ScoreStrategy {
                 double avgViewCountSumSecond = 0D;
                 double maxAvgViewCount = 0D;
                 for (ContentHisPublishArticle hisItem : content.getHisPublishArticleList()) {
-                    // 过滤掉发布时间晚于20点数据
-                    int publishHour = DateUtils.getHourByTimestamp(hisItem.getUpdateTime());
-                    if (publishHour >= 19) {
+                    // 过滤掉发布时间晚于19点数据
+                    if (hisContentLateFilter(hisItem.getUpdateTime())) {
                         continue;
                     }
                     if (hisItem.isInnerAccount() && Objects.nonNull(hisItem.getViewCount())