Bladeren bron

服务号排序 内容池等级默认 不添加缓存 审核过滤

wangyunpeng 1 week geleden
bovenliggende
commit
f8d3f9c7a4

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

@@ -216,7 +216,7 @@ public class RecallService implements ApplicationContextAware {
         }
         long t3 = System.currentTimeMillis();
         // 标题历史均值
-        setTitleAvgViewCount(content, param.getGhId(), param.getType());
+        setTitleAvgViewCount(content, param.getGhId(), param.getType(), param.getStrategy());
         long t4 = System.currentTimeMillis();
         CostMonitor.logCost("Recall", "SetAvgViewCount", t4 - t3);
         // 视频内容池查询抓取时间
@@ -230,12 +230,14 @@ public class RecallService implements ApplicationContextAware {
         }
         // 长文内容池审核过滤
         List<String> sourceIds = content.stream()
-                .filter(o -> !Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal()))
+                .filter(o -> (Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.producePlan.getVal())
+                        || Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.produceContent.getVal())))
                 .map(Content::getSourceId).collect(Collectors.toList());
         List<LongArticleTitleAudit> titleAuditList = titleAuditRepository.getByContentIdIn(sourceIds);
         Map<String, Integer> titleAuditMap = titleAuditList.stream()
                 .collect(Collectors.toMap(LongArticleTitleAudit::getContentId, LongArticleTitleAudit::getStatus));
-        content.removeIf(o -> !Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal())
+        content.removeIf(o -> (Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.producePlan.getVal())
+                || Objects.equals(o.getSourceType(), PublishPlanInputSourceTypesEnum.produceContent.getVal()))
                 && (Objects.isNull(titleAuditMap.get(o.getSourceId()))
                 || titleAuditMap.get(o.getSourceId()) != ArticleVideoAuditStatusEnum.PASS.getCode()));
         if (CollectionUtils.isEmpty(content)) {
@@ -331,7 +333,7 @@ public class RecallService implements ApplicationContextAware {
         }
     }
 
-    public void setTitleAvgViewCount(List<Content> contentList, String ghId, String type) {
+    public void setTitleAvgViewCount(List<Content> contentList, String ghId, String type, String strategy) {
         long start = System.currentTimeMillis();
         contentList.forEach(content -> content.setTitleMd5(Md5Util.encoderByMd5(content.getTitle())));
         List<String> sourceIdList = contentList.stream().map(Content::getSourceId).distinct().collect(Collectors.toList());
@@ -369,11 +371,18 @@ public class RecallService implements ApplicationContextAware {
                 content.setHisPublishArticleList(hisPublishArticleList);
                 setT0Data(content, ghId);
             } else {
-                if (!newCacheSourceIdSet.contains(content.getSourceId())) {
+                if (!newCacheSourceIdSet.contains(content.getSourceId())
+                        && Arrays.asList(PublishPlanInputSourceTypesEnum.producePlan.getVal(),
+                        PublishPlanInputSourceTypesEnum.produceContent.getVal(),
+                        PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal()
+                ).contains(content.getSourceType())) {
                     newCacheSaveList.add(content);
                     newCacheSourceIdSet.add(content.getSourceId());
                 }
             }
+            if (Objects.isNull(content.getContentPoolType()) && RankStrategyEnum.FWH_STRATEGY.getStrategy().equals(strategy)) {
+                content.setContentPoolType(ContentPoolEnum.autoArticlePoolLevel1.getContentPool());
+            }
         }
         // 写入缓存
         saveArticleTitleHisCache(newCacheSaveList, type);

+ 2 - 1
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/ScoreStrategyTest.java

@@ -2,6 +2,7 @@ package com.tzld.longarticle.recommend.server;
 
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleTypeEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.recommend.recall.RecallService;
 import com.tzld.longarticle.recommend.server.service.recommend.score.Score;
@@ -52,7 +53,7 @@ public class ScoreStrategyTest {
         content.setCrawlerChannelContentId("0065561559007185d167afdd61b9ac5a");
         contentList.add(content);
         param.setContents(contentList);
-        recallService.setTitleAvgViewCount(contentList, "gh_bff0bcb0694a", ArticleTypeEnum.QUNFA.getVal());
+        recallService.setTitleAvgViewCount(contentList, "gh_bff0bcb0694a", ArticleTypeEnum.QUNFA.getVal(), RankStrategyEnum.ArticleRankV16.getStrategy());
         System.out.println(JSONObject.toJSONString(param.getContents().get(0).getHisPublishArticleList()));
         List<Score> result = viewCountRateStrategy.score(param);
         System.out.println(JSONObject.toJSONString(result));