Pārlūkot izejas kodu

filterSortContents 分批处理

wangyunpeng 2 nedēļas atpakaļ
vecāks
revīzija
161b2e7e87

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

@@ -1258,15 +1258,17 @@ public class XxlJobService {
                     finalIndex, item.getPlanId(), item.getAccountId(), filterContentList.size());
             recommendService.updateWaitingContentFilter(filterContentList);
             // 调用aigc publish_content待发布内容状态废弃
-            LongArticleSystemFilterSortParam param = new LongArticleSystemFilterSortParam();
-            param.setFilterSortContentList(buildFilterSortContentList(filterResult));
-            aigcPublishContentDiscardService.filterSortContents(param);
+            for (List<Content> partition : Lists.partition(filterResult.getFilterContent(), 1000)) {
+                LongArticleSystemFilterSortParam param = new LongArticleSystemFilterSortParam();
+                param.setFilterSortContentList(buildFilterSortContentList(partition));
+                aigcPublishContentDiscardService.filterSortContents(param);
+            }
         }
     }
 
-    private List<LongArticleSystemFilterSortContentParam> buildFilterSortContentList(FilterResult filterResult) {
+    private List<LongArticleSystemFilterSortContentParam> buildFilterSortContentList(List<Content> filterContents) {
         List<LongArticleSystemFilterSortContentParam> contentList = new ArrayList<>();
-        for (Content filterContent : filterResult.getFilterContent()) {
+        for (Content filterContent : filterContents) {
             LongArticleSystemFilterSortContentParam item = new LongArticleSystemFilterSortContentParam();
             item.setPublishContentId(filterContent.getId());
             item.setFilterReason(filterContent.getFilterReason());

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/filter/strategy/OldStrategy.java

@@ -30,8 +30,10 @@ public class OldStrategy implements FilterStrategy {
         List<String> result = new ArrayList<>();
         List<Content> contents = param.getContents();
         List<Content> filterContents = new ArrayList<>();
+        int contentSize = contents.size();
         for (Content content : contents) {
             if (ContentPoolEnum.autoArticlePoolLevel4.getContentPool().equals(content.getContentPoolType())
+                    && contentSize - filterContents.size() > 20000
                     && ((Objects.nonNull(content.getRootPublishTimestamp())
                     && content.getRootPublishTimestamp() < DateUtils.getTodayStart() - filterOldStrategyRootPublishDays * 86400000L)
                     || content.getCreateTimestamp() < DateUtils.getTodayStart() - filterOldStrategyCreateDays * 86400000L)) {