Bläddra i källkod

Merge branch 'wyp/1030-export-firstScore' of Server/long-article-recommend into master

wangyunpeng 8 månader sedan
förälder
incheckning
cf08491a1f

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/FirstContentScoreExport.java

@@ -26,4 +26,6 @@ public class FirstContentScoreExport {
     private Integer readCount;
     private Double readAvg;
     private Double readAvgRate;
+    // 距首次探索的间隔天数
+    private Integer firstExplorationIntervalAvg;
 }

+ 9 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/DataDashboardService.java

@@ -31,6 +31,7 @@ import com.tzld.longarticle.recommend.server.repository.crawler.PublishSortLogRe
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreStrategy;
 import com.tzld.longarticle.recommend.server.util.DateUtils;
 import com.tzld.longarticle.recommend.server.util.MapBuilder;
+import com.tzld.longarticle.recommend.server.util.Md5Util;
 import com.tzld.longarticle.recommend.server.util.feishu.FeiShu;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
@@ -1379,6 +1380,10 @@ public class DataDashboardService {
                 Collectors.groupingBy(Article::getGhId, Collectors.toMap(
                         o -> DateUtils.timestampToYMDStr(o.getUpdateTime(), "yyyyMMdd"), o -> o,
                         (existing, replacement) -> replacement)));
+        List<String> titleList = articleList.stream().map(Article::getTitle).distinct().collect(Collectors.toList());
+        List<String> titleMd5s = titleList.stream().map(Md5Util::encoderByMd5).collect(Collectors.toList());
+        List<Article> hisPublishList = articleRepository.getByTitleMd5InAndTypeEqualsAndStatusEquals(titleMd5s, ArticleTypeEnum.QUNFA.getVal(), 1);
+        Map<String, List<Article>> hisPublishMap = hisPublishList.stream().collect(Collectors.groupingBy(Article::getTitle));
         String ymd = DateUtils.timestampToYMDStr(minTimestamp - 86400 * 7, "yyyy-MM-dd");
         List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByUpdateTimeGreaterThanEqual(ymd);
         Map<String, Map<String, AccountAvgInfo>> accountAvgInfoMap = accountAvgInfoList.stream()
@@ -1430,6 +1435,10 @@ public class DataDashboardService {
                     item.setReadAvgRate(article.getShowViewCount() / (double) accountAvgInfo.getReadAvg());
                 }
             }
+            List<Article> hisPublish = hisPublishMap.get(article.getTitle());
+            Long hisMinDate = hisPublish.stream().mapToLong(Article::getUpdateTime).min().orElse(0);
+            int explorationInterval = (int) ((article.getUpdateTime() - hisMinDate) / 86400);
+            item.setFirstExplorationIntervalAvg(explorationInterval);
             result.add(item);
         }
         result.sort(Comparator.comparing(FirstContentScoreExport::getDateStr).reversed()