|
@@ -1,7 +1,5 @@
|
|
|
package com.tzld.piaoquan.recommend.server.service.filter;
|
|
|
|
|
|
-import com.google.common.base.Stopwatch;
|
|
|
-import com.thoughtworks.xstream.mapper.Mapper;
|
|
|
import com.tzld.piaoquan.recommend.server.service.PreViewedService;
|
|
|
import com.tzld.piaoquan.recommend.server.service.ViewedService;
|
|
|
import com.tzld.piaoquan.recommend.server.util.JSONUtils;
|
|
@@ -21,7 +19,6 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
public abstract class AbstractFilterService implements FilterService {
|
|
|
- public Integer forceTruncation;
|
|
|
@Autowired
|
|
|
private PreViewedService preViewedService;
|
|
|
|
|
@@ -29,14 +26,18 @@ public abstract class AbstractFilterService implements FilterService {
|
|
|
private ViewedService viewedService;
|
|
|
|
|
|
|
|
|
-
|
|
|
protected List<Long> viewFilter(FilterParam param) {
|
|
|
|
|
|
|
|
|
List<Long> videoIds = filterWithRiskVideo(param.getRiskFilterFlag(),
|
|
|
param.getAppType(), param.getRegionCode(), param.getAppRegionFiltered(), param.getVideosWithRisk(),
|
|
|
+<<<<<<< HEAD
|
|
|
param.getVideoIds());
|
|
|
|
|
|
+=======
|
|
|
+ param.getVideoIds(), param.getForceTruncation());
|
|
|
+ log.info("filterByRiskVideos videoIds={}", JSONUtils.toJson(videoIds));
|
|
|
+>>>>>>> 5917e10 (compatible)
|
|
|
videoIds = filterByPreViewed(param.getAppType(), param.getMid(), videoIds);
|
|
|
|
|
|
videoIds = filterByViewed(param.getAppType(), param.getMid(), param.getUid(), videoIds);
|
|
@@ -73,22 +74,23 @@ public abstract class AbstractFilterService implements FilterService {
|
|
|
String regionCode,
|
|
|
Map<Integer, List<String>> rules,
|
|
|
List<Long> videosWithRisk,
|
|
|
- List<Long> videoIds){
|
|
|
- if (!riskFlag){
|
|
|
- return this.truncation(videoIds);
|
|
|
+ List<Long> videoIds,
|
|
|
+ int forceTruncation) {
|
|
|
+ if (!riskFlag) {
|
|
|
+ return this.truncation(videoIds, forceTruncation);
|
|
|
}
|
|
|
|
|
|
boolean filterFlag;
|
|
|
- if (rules.containsKey(appType)){
|
|
|
+ if (rules.containsKey(appType)) {
|
|
|
filterFlag = false;
|
|
|
- if (rules.get(appType).contains(regionCode)){
|
|
|
+ if (rules.get(appType).contains(regionCode)) {
|
|
|
filterFlag = true;
|
|
|
}
|
|
|
} else {
|
|
|
filterFlag = true;
|
|
|
}
|
|
|
- if (!filterFlag){
|
|
|
- return this.truncation(videoIds);
|
|
|
+ if (!filterFlag) {
|
|
|
+ return this.truncation(videoIds, forceTruncation);
|
|
|
}
|
|
|
|
|
|
List<Long> videoIdNew = new ArrayList<>();
|
|
@@ -97,13 +99,14 @@ public abstract class AbstractFilterService implements FilterService {
|
|
|
videoIdNew.add(videoId);
|
|
|
}
|
|
|
}
|
|
|
- return this.truncation(videoIdNew);
|
|
|
+ return this.truncation(videoIdNew, forceTruncation);
|
|
|
}
|
|
|
- private List<Long> truncation(List<Long> videoIds){
|
|
|
- if (this.forceTruncation == null){
|
|
|
+
|
|
|
+ private List<Long> truncation(List<Long> videoIds, int forceTruncation) {
|
|
|
+ if (forceTruncation == 0) {
|
|
|
return videoIds;
|
|
|
- }else{
|
|
|
- return videoIds.subList(0, Math.min(this.forceTruncation, videoIds.size()));
|
|
|
+ } else {
|
|
|
+ return videoIds.subList(0, Math.min(forceTruncation, videoIds.size()));
|
|
|
}
|
|
|
}
|
|
|
}
|