Browse Source

阅读均值倍数评分 过滤掉发布时间晚于20点数据

wangyunpeng 9 months ago
parent
commit
2a3749fd1f

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

@@ -66,7 +66,7 @@ public class RankV5Strategy implements RankStrategy {
             return item;
         });
         // 相似度评分为0 报警返回
-               if (CollectionUtils.isNotEmpty(items)
+        if (CollectionUtils.isNotEmpty(items)
                 && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
                 && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
             FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",

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

@@ -9,6 +9,7 @@ import com.tzld.longarticle.recommend.server.service.AccountIndexAvgViewCountSer
 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;
@@ -68,6 +69,11 @@ 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 >= 20) {
+                        continue;
+                    }
                     if (hisItem.isInnerAccount() && Objects.nonNull(hisItem.getViewCount())
                             && hisItem.getViewCount() > 0 && Objects.nonNull(hisItem.getAvgViewCount())
                             && hisItem.getAvgViewCount() > 0) {

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

@@ -9,6 +9,7 @@ import com.tzld.longarticle.recommend.server.service.AccountIndexAvgViewCountSer
 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;
@@ -68,6 +69,11 @@ 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 >= 20) {
+                        continue;
+                    }
                     if (hisItem.isInnerAccount() && Objects.nonNull(hisItem.getViewCount())
                             && hisItem.getViewCount() > 0 && Objects.nonNull(hisItem.getAvgViewCount())
                             && hisItem.getAvgViewCount() > 0) {