Browse Source

晚于19点发布文章不进行评分计算

wangyunpeng 9 tháng trước cách đây
mục cha
commit
581a983788

+ 4 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/RecallService.java

@@ -18,6 +18,7 @@ import com.tzld.longarticle.recommend.server.repository.crawler.ArticleDetailInf
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.AccountIndexAvgViewCountService;
 import com.tzld.longarticle.recommend.server.service.recall.strategy.DefaultRecallStrategy;
+import com.tzld.longarticle.recommend.server.service.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.DateUtils;
 import com.tzld.longarticle.recommend.server.util.JSONUtils;
@@ -276,6 +277,9 @@ public class RecallService implements ApplicationContextAware {
             }
             content.setHisPublishArticleList(new ArrayList<>());
             for (Article hisArticle : hisArticles) {
+                if (ScoreStrategy.hisContentLateFilter(hisArticle.getUpdateTime())) {
+                    continue;
+                }
                 ContentHisPublishArticle article = new ContentHisPublishArticle();
                 BeanUtils.copyProperties(hisArticle, article);
                 article.setViewCount(hisArticle.getShowViewCount());

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

@@ -11,7 +11,7 @@ import java.util.List;
 public interface ScoreStrategy {
     List<Score> score(ScoreParam param);
 
-    public default boolean hisContentLateFilter(Long publishTime) {
+    public static boolean hisContentLateFilter(Long publishTime) {
         // 过滤掉发布时间晚于19点数据
         int publishHour = DateUtils.getHourByTimestamp(publishTime);
         return publishHour >= 19;

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

@@ -69,7 +69,7 @@ public class ViewCountRateCorrelationStrategy implements ScoreStrategy {
                 double maxAvgViewCount = 0D;
                 for (ContentHisPublishArticle hisItem : content.getHisPublishArticleList()) {
                     // 过滤掉发布时间晚于19点数据
-                    if (hisContentLateFilter(hisItem.getUpdateTime())) {
+                    if (ScoreStrategy.hisContentLateFilter(hisItem.getUpdateTime())) {
                         continue;
                     }
                     if (hisItem.isInnerAccount() && Objects.nonNull(hisItem.getViewCount())

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

@@ -69,7 +69,7 @@ public class ViewCountRateStrategy implements ScoreStrategy {
                 double maxAvgViewCount = 0D;
                 for (ContentHisPublishArticle hisItem : content.getHisPublishArticleList()) {
                     // 过滤掉发布时间晚于19点数据
-                    if (hisContentLateFilter(hisItem.getUpdateTime())) {
+                    if (ScoreStrategy.hisContentLateFilter(hisItem.getUpdateTime())) {
                         continue;
                     }
                     if (hisItem.isInnerAccount() && Objects.nonNull(hisItem.getViewCount())