Browse Source

阅读均值计算修改

wangyunpeng 8 tháng trước cách đây
mục cha
commit
2d5c3780a2

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

@@ -15,5 +15,5 @@ public class ContentHisPublishArticle {
     private Long updateTime;
     private Integer avgViewCount;
     private Double viewCountRate;
-
+    private boolean isInnerAccount;
 }

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

@@ -1,5 +1,7 @@
 package com.tzld.longarticle.recommend.server.service.recall;
 
+import cn.hutool.core.io.resource.ResourceUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.model.ContentHisPublishArticle;
@@ -9,6 +11,7 @@ import com.tzld.longarticle.recommend.server.repository.entity.aigc.CrawlerMetaA
 import com.tzld.longarticle.recommend.server.repository.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.service.recall.strategy.ColdStartBackupRecallStrategy;
 import com.tzld.longarticle.recommend.server.service.recall.strategy.DefaultRecallStrategy;
+import com.tzld.longarticle.recommend.server.service.score.AvgReadDTO;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.JSONUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -126,19 +129,18 @@ public class RecallService implements ApplicationContextAware {
 
     public void setTitleAvgViewCount(List<Content> contentList) {
         long start = System.currentTimeMillis();
+        String cardJSON = ResourceUtil.readUtf8Str("file/AccountInfo.json");
+        JSONObject jsonObject = JSONObject.parseObject(cardJSON);
         List<String> titleList = contentList.stream().map(Content::getTitle).collect(Collectors.toList());
         List<Article> hisArticleList = articleRepository.getByTitleIn(titleList);
         Map<String, Map<Integer, List<Article>>> map = hisArticleList.stream()
                 .collect(Collectors.groupingBy(Article::getTitle, Collectors.groupingBy(Article::getItemIndex)));
         for (Content content : contentList) {
             List<Article> hisArticles = new ArrayList<>();
-            Map<Integer, Integer> indexAvgMap = new HashMap<>();
             Map<Integer, List<Article>> indexArticleMap = map.get(content.getTitle());
             if (Objects.nonNull(indexArticleMap) && !indexArticleMap.isEmpty()) {
                 for (Map.Entry<Integer, List<Article>> indexArticleEntry : indexArticleMap.entrySet()) {
                     List<Article> indexArticleList = indexArticleEntry.getValue();
-                    int sumViewCount = indexArticleList.stream().mapToInt(Article::getShowViewCount).sum();
-                    indexAvgMap.put(indexArticleEntry.getKey(), sumViewCount/ indexArticleList.size());
                     hisArticles.addAll(indexArticleList);
                 }
             }
@@ -146,7 +148,13 @@ public class RecallService implements ApplicationContextAware {
             for (Article hisArticle : hisArticles) {
                 ContentHisPublishArticle article = new ContentHisPublishArticle();
                 BeanUtils.copyProperties(hisArticle, article);
-                article.setAvgViewCount(indexAvgMap.get(article.getItemIndex()));
+                AvgReadDTO dto = jsonObject.getObject(hisArticle.getGhId() + "_" + hisArticle.getItemIndex(), AvgReadDTO.class);
+                int avgViewCount = 0;
+                if (Objects.nonNull(dto)) {
+                    article.setInnerAccount(true);
+                    avgViewCount = (int) dto.getReadAvg();
+                }
+                article.setAvgViewCount(avgViewCount);
                 if (Objects.nonNull(article.getAvgViewCount()) && article.getAvgViewCount() > 0) {
                     article.setViewCountRate((article.getShowViewCount() * 1.0) / article.getAvgViewCount());
                 }

+ 3 - 3
long-article-recommend-service/src/main/resources/application-dev.yml

@@ -15,7 +15,7 @@ spring:
 #        min-idle: 0
   datasource:
     crawler:
-      jdbc-url: jdbc:mysql://rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: crawler
       password: crawler123456@
       driver-class-name: com.mysql.jdbc.Driver
@@ -26,7 +26,7 @@ spring:
         auto-commit: true
         idle-timeout: 30000
     adplatform:
-      jdbc-url: jdbc:mysql://rm-bp12k5fuh5zyx31d28o.mysql.rds.aliyuncs.com:3306/adplatform?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-bp12k5fuh5zyx31d28o.mysql.rds.aliyuncs.com:3306/adplatform?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: wx2023_ad
       password: wx2023_adP@assword1234
       driver-class-name: com.mysql.jdbc.Driver
@@ -37,7 +37,7 @@ spring:
         auto-commit: true
         idle-timeout: 30000
     aigc:
-      jdbc-url: jdbc:mysql://rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com:3306/aigc-admin-prod?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com:3306/aigc-admin-prod?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: crawler_admin
       password: cyber#crawler_2023
       driver-class-name: com.mysql.jdbc.Driver

+ 3 - 3
long-article-recommend-service/src/main/resources/application-pre.yml

@@ -85,7 +85,7 @@ spring:
       maxSize: 100
   datasource:
     crawler:
-      jdbc-url: jdbc:mysql://rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: crawler
       password: crawler123456@
       driver-class-name: com.mysql.jdbc.Driver
@@ -96,7 +96,7 @@ spring:
         auto-commit: true
         idle-timeout: 30000
     adplatform:
-      jdbc-url: jdbc:mysql://rm-bp12k5fuh5zyx31d28o.mysql.rds.aliyuncs.com:3306/adplatform?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-bp12k5fuh5zyx31d28o.mysql.rds.aliyuncs.com:3306/adplatform?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: wx2023_ad
       password: wx2023_adP@assword1234
       driver-class-name: com.mysql.jdbc.Driver
@@ -107,7 +107,7 @@ spring:
         auto-commit: true
         idle-timeout: 30000
     aigc:
-      jdbc-url: jdbc:mysql://rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com:3306/aigc-admin-prod?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com:3306/aigc-admin-prod?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: crawler_admin
       password: cyber#crawler_2023
       driver-class-name: com.mysql.jdbc.Driver

+ 3 - 3
long-article-recommend-service/src/main/resources/application-prod.yml

@@ -4,7 +4,7 @@ server:
 spring:
   datasource:
     crawler:
-      jdbc-url: jdbc:mysql://rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: crawler
       password: crawler123456@
       driver-class-name: com.mysql.jdbc.Driver
@@ -15,7 +15,7 @@ spring:
         auto-commit: true
         idle-timeout: 30000
     adplatform:
-      jdbc-url: jdbc:mysql://rm-bp12k5fuh5zyx31d28o.mysql.rds.aliyuncs.com:3306/adplatform?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-bp12k5fuh5zyx31d28o.mysql.rds.aliyuncs.com:3306/adplatform?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: wx2023_ad
       password: wx2023_adP@assword1234
       driver-class-name: com.mysql.jdbc.Driver
@@ -26,7 +26,7 @@ spring:
         auto-commit: true
         idle-timeout: 30000
     aigc:
-      jdbc-url: jdbc:mysql://rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com:3306/aigc-admin-prod?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com:3306/aigc-admin-prod?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: crawler_admin
       password: cyber#crawler_2023
       driver-class-name: com.mysql.jdbc.Driver

+ 3 - 3
long-article-recommend-service/src/main/resources/application-test.yml

@@ -75,7 +75,7 @@ spring:
       maxSize: 10
   datasource:
     crawler:
-      jdbc-url: jdbc:mysql://rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: crawler
       password: crawler123456@
       driver-class-name: com.mysql.jdbc.Driver
@@ -86,7 +86,7 @@ spring:
         auto-commit: true
         idle-timeout: 30000
     adplatform:
-      jdbc-url: jdbc:mysql://rm-bp12k5fuh5zyx31d28o.mysql.rds.aliyuncs.com:3306/adplatform?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-bp12k5fuh5zyx31d28o.mysql.rds.aliyuncs.com:3306/adplatform?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: wx2023_ad
       password: wx2023_adP@assword1234
       driver-class-name: com.mysql.jdbc.Driver
@@ -97,7 +97,7 @@ spring:
         auto-commit: true
         idle-timeout: 30000
     aigc:
-      jdbc-url: jdbc:mysql://rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com:3306/aigc-admin-prod?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
+      jdbc-url: jdbc:mysql://rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com:3306/aigc-admin-prod?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
       username: crawler_admin
       password: cyber#crawler_2023
       driver-class-name: com.mysql.jdbc.Driver