|
@@ -1,16 +1,19 @@
|
|
|
package com.tzld.piaoquan.recommend.server.service.filter;
|
|
|
|
|
|
+import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.tzld.piaoquan.recommend.server.common.ThreadPoolFactory;
|
|
|
import com.tzld.piaoquan.recommend.server.service.ServiceBeanFactory;
|
|
|
import com.tzld.piaoquan.recommend.server.service.filter.strategy.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.RandomUtils;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Future;
|
|
@@ -24,6 +27,8 @@ import java.util.concurrent.TimeUnit;
|
|
|
public class FilterService {
|
|
|
|
|
|
private final ExecutorService pool = ThreadPoolFactory.filterPool();
|
|
|
+ @ApolloJsonValue("${filter_exp_config:{}}")
|
|
|
+ private Map<String, Integer> filterExpConfig;
|
|
|
|
|
|
public FilterResult filter(FilterParam param) {
|
|
|
List<Long> videoIds = viewFilter(param);
|
|
@@ -77,14 +82,34 @@ public class FilterService {
|
|
|
strategies.add(ServiceBeanFactory.getBean(AppletVideoStatusStrategy.class));
|
|
|
strategies.add(ServiceBeanFactory.getBean(RiskVideoStrategy.class));
|
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(param.getAbExpCodes()) && param.getAbExpCodes().contains("697")) {
|
|
|
- strategies.add(ServiceBeanFactory.getBean(VideoSourceTypeStrategy.class));
|
|
|
+ // UGC视频过滤
|
|
|
+ Integer ugcFilterWeight = filterExpConfig.get("userupload");
|
|
|
+ if (ugcFilterWeight != null && ugcFilterWeight != 0) {
|
|
|
+ int rand = RandomUtils.nextInt(0, 100);
|
|
|
+ if (ugcFilterWeight >= 100 || rand < ugcFilterWeight) {
|
|
|
+ // log.info("hit ugc filter weight:{} rand:{}", ugcFilterWeight, rand);
|
|
|
+ strategies.add(ServiceBeanFactory.getBean(VideoSourceTypeStrategy.class));
|
|
|
+ }
|
|
|
}
|
|
|
- //全面spider视频过滤
|
|
|
- if (CollectionUtils.isNotEmpty(param.getAbExpCodes()) && param.getAbExpCodes().contains("722")) {
|
|
|
- strategies.add(ServiceBeanFactory.getBean(GeneralSpiderStrategy.class));
|
|
|
+
|
|
|
+ // 全面spider视频过滤
|
|
|
+ Integer allSpiderFilterWeight = filterExpConfig.get("allspider");
|
|
|
+ if (allSpiderFilterWeight != null && allSpiderFilterWeight != 0) {
|
|
|
+ int rand = RandomUtils.nextInt(0, 100);
|
|
|
+ if (allSpiderFilterWeight >= 100 || rand < allSpiderFilterWeight) {
|
|
|
+ // log.info("hit all spider filter weight:{} rand:{}", allSpiderFilterWeight, rand);
|
|
|
+ strategies.add(ServiceBeanFactory.getBean(GeneralSpiderStrategy.class));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+// if (CollectionUtils.isNotEmpty(param.getAbExpCodes()) && param.getAbExpCodes().contains("697")) {
|
|
|
+// strategies.add(ServiceBeanFactory.getBean(VideoSourceTypeStrategy.class));
|
|
|
+// }
|
|
|
+// //全面spider视频过滤
|
|
|
+// if (CollectionUtils.isNotEmpty(param.getAbExpCodes()) && param.getAbExpCodes().contains("722")) {
|
|
|
+// strategies.add(ServiceBeanFactory.getBean(GeneralSpiderStrategy.class));
|
|
|
+// }
|
|
|
+
|
|
|
return strategies;
|
|
|
}
|
|
|
|