Bladeren bron

2025-04-15 冷启动晋级优化

luojunhui 1 week geleden
bovenliggende
commit
417188b5cc

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/longArticle/LongArticleBaseMapper.java

@@ -32,7 +32,7 @@ public interface LongArticleBaseMapper {
     List<DatastatSortStrategy> getArticlePromotion(Integer viewCount, Double viewCountRate,
                                                    Integer fans, String dateStr, List<Integer> positions);
 
-    List<DatastatSortStrategy> getArticlePromotionV2(Integer fans, String dateStr, List<Integer> positions);
+    List<DatastatSortStrategy> getArticlePromotionCandidates(Integer fans, String dateStr, List<Integer> positions);
 
     void batchInsertLongArticlesRootSourceId(List<LongArticlesRootSourceId> list);
 

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

@@ -139,7 +139,7 @@ public class ArticlePromotionService {
         // 获取内部表现
         List<DatastatSortStrategy> list;
         if (pos.equals("【2】")) {
-            list = longArticleBaseMapper.getArticlePromotionV2(10000, dateStrFilter, positionFilter);
+            list = longArticleBaseMapper.getArticlePromotionCandidates(10000, dateStrFilter, positionFilter);
 
             // 使用阅读均值倍数+阅读量晋级
             List<DatastatSortStrategy> listStrategy1 = list.stream()
@@ -150,37 +150,23 @@ public class ArticlePromotionService {
             List<DatastatSortStrategy> listStrategy2 = list.stream()
                     .filter(o -> {
                         try {
-                            return abZTestCorrected(
-                                    o.getAvgViewCount() * 1.1 * 30,
-                                    o.getFans() * 30,
-                                    o.getViewCount(),
-                                    o.getFans(),
-                                    0.95
-                            );
-                        } catch (IllegalArgumentException e) {
-                            // 记录异常日志(包含对象标识)
-                            log.error("显著性检验,传入数值错误: {}", e.getMessage());
-                            return false; // 异常时过滤掉该对象
-                        } catch (Exception e) {
-                            // 捕获其他未预期异常
-                            log.error("显著性检验, 其他异常: {}", e.getMessage());
+                            return abZTestCorrected(o.getAvgViewCount() * 1.1 * 30, o.getFans() * 30,
+                                    o.getViewCount(), o.getFans(), 0.95);
+                        }
+                        catch (Exception e) {
+                            log.error("显著性检验, 出现异常: {}", e.getMessage());
                             return false;
                         }
                     })
                     .collect(Collectors.toList());
 
-            // merge 两个 list, 通过wx_sn去重
-            // 临时用 Map 存储去重(保留第一个出现的元素)
             list = Stream.concat(listStrategy1.stream(), listStrategy2.stream())
-                    // 使用标题作为去重标识
                     .collect(Collectors.collectingAndThen(
-                            // 临时用 Map 存储去重(保留第一个出现的元素)
                             Collectors.toMap(
                                     DatastatSortStrategy::getWxSn,
                                     Function.identity(),
-                                    (existing, replacement) -> existing // 冲突时保留已有元素
+                                    (existing, replacement) -> existing
                             ),
-                            // 从 Map 的 values 中提取结果
                             map -> new ArrayList<>(map.values())
                     ));
         } else {

+ 1 - 1
long-article-recommend-service/src/main/resources/mapper/longArticle/LongArticleBaseMapper.xml

@@ -111,7 +111,7 @@
         </foreach>
     </select>
 
-    <select id="getArticlePromotionV2"
+    <select id="getArticlePromotionCandidates"
             resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy">
         select *
         from datastat_sort_strategy