Pārlūkot izejas kodu

生成计划输入仅保留最近50条

wangyunpeng 4 nedēļas atpakaļ
vecāks
revīzija
855d71e878

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

@@ -187,8 +187,7 @@ public class ArticlePromotionService {
                         try {
                             return isExperimentGroupStatisticallySuperior(o.getAvgViewCount() * 1.1 * 30, o.getFans() * 30,
                                     o.getViewCount(), o.getFans(), 0.95);
-                        }
-                        catch (Exception e) {
+                        } catch (Exception e) {
                             log.error("显著性检验, 出现异常: {}", e.getMessage());
                             return false;
                         }
@@ -483,6 +482,11 @@ public class ArticlePromotionService {
             }
             // 获取依赖计划 ID 列表
             List<ProducePlanInputSourceParam> inputSources = detail.getInputSourceGroups().get(0).getInputSources();
+            // 计划输入仅保留最近50条
+            if (inputSources.size() > 50) {
+                inputSources.sort(Comparator.comparing(ProducePlanInputSourceParam::getInputSourceValue));
+                detail.getInputSourceGroups().get(0).setInputSources(inputSources.subList(inputSources.size() - 50, inputSources.size()));
+            }
             List<String> dependValues = new ArrayList<>();
             for (ProducePlanInputSourceParam inputSource : inputSources) {
                 dependValues.add(inputSource.getInputSourceValue());
@@ -653,7 +657,7 @@ public class ArticlePromotionService {
             try {
                 Thread.sleep(1000);
             } catch (InterruptedException e) {
-                log.error( "topContentReSendJob detail sleep error: ", e);
+                log.error("topContentReSendJob detail sleep error: ", e);
             }
         }
         if (Objects.isNull(detail)) {