Преглед изворни кода

账号头条发布得分 导出 距首次探索的间隔天数 仅查看系统内发布文章

wangyunpeng пре 8 месеци
родитељ
комит
bea3126e87

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java

@@ -30,4 +30,6 @@ public interface AigcBaseMapper {
     List<ProduceContentDTO> getSourceProduceContentByTitles(List<String> titleList);
 
     List<AccountTypeFansDTO> getAccountTypeFans();
+
+    List<PublishContent> getHisPublishByTitles(List<String> titleList);
 }

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

@@ -31,7 +31,6 @@ 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;
@@ -1381,9 +1380,11 @@ public class DataDashboardService {
                         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));
+        List<PublishContent> hisPublishList = new ArrayList<>();
+        for (List<String> partitions : Lists.partition(new ArrayList<>(titleList), 100)) {
+            hisPublishList.addAll(aigcBaseMapper.getHisPublishByTitles(partitions));
+        }
+        Map<String, List<PublishContent>> hisPublishMap = hisPublishList.stream().collect(Collectors.groupingBy(PublishContent::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()
@@ -1435,9 +1436,9 @@ 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);
+            List<PublishContent> hisPublish = hisPublishMap.get(article.getTitle());
+            long hisMinDate = hisPublish.stream().mapToLong(PublishContent::getPublishTimestamp).min().orElse(0);
+            int explorationInterval = (int) ((article.getUpdateTime() - (hisMinDate / 1000)) / 86400);
             item.setFirstExplorationIntervalAvg(explorationInterval);
             result.add(item);
         }

+ 13 - 0
long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml

@@ -131,5 +131,18 @@
           AND t3.channel = 5
     </select>
 
+    <select id="getHisPublishByTitles"
+            resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.PublishContent">
+        select content.*, output.output as title
+        from publish_content content
+        join publish_content_output output
+        on content.id = output.publish_content_id and output.content_type = 3 AND output.select_status = 1
+        where content.status = 2
+          and output.output in
+        <foreach collection="titleList" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
+
 
 </mapper>