|
|
@@ -7,6 +7,7 @@ import com.google.common.cache.CacheBuilder;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.tzld.longarticle.recommend.server.common.ContentCountMonitor;
|
|
|
import com.tzld.longarticle.recommend.server.common.CostMonitor;
|
|
|
+import com.tzld.longarticle.recommend.server.common.constant.SceneConstants;
|
|
|
import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.LongArticleTextSimilarityStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
|
|
|
@@ -222,6 +223,11 @@ public class RecallService implements ApplicationContextAware {
|
|
|
+ "账号名称: " + param.getAccountName());
|
|
|
return content;
|
|
|
}
|
|
|
+ // 根据 publishNum 过滤内容池
|
|
|
+ content = filterByPublishNum(content, param);
|
|
|
+ if (CollectionUtils.isEmpty(content)) {
|
|
|
+ return content;
|
|
|
+ }
|
|
|
long t3 = System.currentTimeMillis();
|
|
|
// 标题历史均值
|
|
|
setTitleAvgViewCount(content, param.getGhId(), param.getType(), param.getStrategy());
|
|
|
@@ -232,6 +238,44 @@ public class RecallService implements ApplicationContextAware {
|
|
|
return content;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据 publishNum 过滤内容池
|
|
|
+ * publishNum == 1: 只返回头条内容 (autoArticlePoolLevel1, autoArticlePoolLevel2)
|
|
|
+ * publishNum == 2: 只返回头条+次条内容 (autoArticlePoolLevel1, autoArticlePoolLevel2, autoArticlePoolLevel3)
|
|
|
+ * 需求策略下 publishNum == 1 或 2: 额外增加利用池内容 (accountDemandPoolLevelUtilize),不返回冷启池 (accountDemandPoolLevelCold)
|
|
|
+ */
|
|
|
+ private List<Content> filterByPublishNum(List<Content> content, RecallParam param) {
|
|
|
+ Integer publishNum = param.getPublishNum();
|
|
|
+ if (publishNum == null || publishNum > 2) {
|
|
|
+ return content;
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean isDemandStrategy = SceneConstants.DEMAND_POOL.equals(param.getScene());
|
|
|
+
|
|
|
+ Set<String> allowedPools = new HashSet<>();
|
|
|
+ // 头条: level 1, 2
|
|
|
+ allowedPools.add(ContentPoolEnum.autoArticlePoolLevel1.getContentPool());
|
|
|
+ allowedPools.add(ContentPoolEnum.autoArticlePoolLevel2.getContentPool());
|
|
|
+
|
|
|
+ if (publishNum == 2) {
|
|
|
+ // 次条: level 3
|
|
|
+ allowedPools.add(ContentPoolEnum.autoArticlePoolLevel3.getContentPool());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isDemandStrategy) {
|
|
|
+ // 需求策略: 增加利用池,排除冷启池
|
|
|
+ allowedPools.add(ContentPoolEnum.accountDemandPoolLevelUtilize.getContentPool());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Content> filtered = content.stream()
|
|
|
+ .filter(c -> c.getContentPoolType() == null || allowedPools.contains(c.getContentPoolType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ log.info("filterByPublishNum publishNum:{}, isDemandStrategy:{}, before:{}, after:{}",
|
|
|
+ publishNum, isDemandStrategy, content.size(), filtered.size());
|
|
|
+ return filtered;
|
|
|
+ }
|
|
|
+
|
|
|
private void filterAuditPassContent(List<Content> content) {
|
|
|
if (CollectionUtils.isEmpty(content)) {
|
|
|
return;
|