Selaa lähdekoodia

video insight

丁云鹏 1 kuukausi sitten
vanhempi
commit
262944aaed

+ 50 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/repository/VideoDemandAnalysis.java

@@ -0,0 +1,50 @@
+package com.tzld.piaoquan.recommend.server.repository;
+
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.util.Date;
+
+@Data
+@Entity
+@Table(name = "video_demand_analysis")
+public class VideoDemandAnalysis {
+    @Id
+    private Integer id;
+
+    private Long videoId;
+
+    private String videoLink;
+
+    private String videoTitle;
+
+    private String contentType;
+
+    private Integer demandOrder;
+
+    private Integer demandScore;
+
+    private String demandCategory;
+
+    private String hookTime;
+
+    private String hookType;
+
+    private String landingType;
+
+    private Date createdAt;
+
+    private String userDemand;
+
+    private String demandReason;
+
+    private String productHook;
+
+    private String hookDesc;
+
+    private String landingDesc;
+
+    private String platformCase;
+}

+ 18 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/repository/VideoDemandAnalysisRepository.java

@@ -0,0 +1,18 @@
+package com.tzld.piaoquan.recommend.server.repository;
+
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * @Author dyp
+ */
+@Repository
+public interface VideoDemandAnalysisRepository extends JpaRepository<VideoDemandAnalysis, Long> {
+    @Query("SELECT DISTINCT v.videoId FROM VideoDemandAnalysis v order by id desc")
+    List<Long> findDistinctVideoId(Pageable pageable);
+}

+ 0 - 1
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/RecommendService.java

@@ -387,7 +387,6 @@ public class RecommendService {
     public RecallParam convertToRecallParam(RecommendParam param) {
         RecallParam recallParam = new RecallParam();
         recallParam.setAppType(param.getAppType());
-        // hard code 算法实验配置化之前,复用abcode做AB验证
         // note 避免非实验产品被覆盖
         recallParam.setRuleKey(param.getRuleKey());
         recallParam.setDataKey(param.getDataKey());

+ 1 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/RankRouter.java

@@ -27,6 +27,7 @@ public class RankRouter {
         STRATEGY_CLASSES.put("567", RankStrategy4RegionMergeModelV567.class);
         STRATEGY_CLASSES.put("569", RankStrategy4RegionMergeModelV569.class);
         STRATEGY_CLASSES.put("568", RankStrategy4RegionMergeModelV568.class);
+        STRATEGY_CLASSES.put("9999", RankStrategy4Alpha.class);
     }
 
     @Autowired

+ 42 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/rank/strategy/RankStrategy4Alpha.java

@@ -0,0 +1,42 @@
+package com.tzld.piaoquan.recommend.server.service.rank.strategy;
+
+import com.tzld.piaoquan.recommend.server.model.Video;
+import com.tzld.piaoquan.recommend.server.service.rank.RankParam;
+import com.tzld.piaoquan.recommend.server.service.rank.RankResult;
+import com.tzld.piaoquan.recommend.server.service.rank.RankService;
+import com.tzld.piaoquan.recommend.server.service.recall.strategy.VideoInsightRecallStrategy;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+@Service
+@Slf4j
+public class RankStrategy4Alpha extends RankService {
+
+    public RankResult rank(RankParam param) {
+        if (param == null
+                || param.getRecallResult() == null
+                || CollectionUtils.isEmpty(param.getRecallResult().getData())) {
+            return null;
+        }
+
+        List<Video> results = new ArrayList<>(extractAndSort(param, VideoInsightRecallStrategy.PUSH_FORM));
+        results = results.subList(0, Math.min(results.size(), param.getSize()));
+        return new RankResult(results);
+
+    }
+
+    @Override
+    public List<Video> mergeAndRankRovRecall(RankParam param) {
+        return null;
+    }
+
+    @Override
+    public RankResult mergeAndSort(RankParam param, List<Video> rovRecallRank, List<Video> flowPoolRank) {
+        return null;
+    }
+}

+ 6 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/RecallService.java

@@ -88,6 +88,12 @@ public class RecallService implements ApplicationContextAware {
             strategies.add(strategyMap.get(SpecialRecallStrategy.class.getSimpleName()));
             return strategies;
         }
+        if (CollectionUtils.isNotEmpty(param.getAbExpCodes())
+                && param.getAbExpCodes().contains("9999")) {
+            // 内测逻辑
+            strategies.add(strategyMap.get(VideoInsightRecallStrategy.class.getSimpleName()));
+            return strategies;
+        }
 
         //1:通过“产品”控制“召回子策略”. 票圈美好祝福与内部tab只走祝福召回。APP只走固定列表。特殊配置的app只有固定召回列表。
         if (this.matchSpecialApp(param.getAppType())) {

+ 59 - 0
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/VideoInsightRecallStrategy.java

@@ -0,0 +1,59 @@
+package com.tzld.piaoquan.recommend.server.service.recall.strategy;
+
+import com.tzld.piaoquan.recommend.server.model.Video;
+import com.tzld.piaoquan.recommend.server.repository.VideoDemandAnalysisRepository;
+import com.tzld.piaoquan.recommend.server.service.filter.FilterParam;
+import com.tzld.piaoquan.recommend.server.service.filter.FilterResult;
+import com.tzld.piaoquan.recommend.server.service.filter.FilterService;
+import com.tzld.piaoquan.recommend.server.service.recall.FilterParamFactory;
+import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
+import com.tzld.piaoquan.recommend.server.service.recall.RecallStrategy;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+/**
+ * @author dyp
+ */
+@Component
+public class VideoInsightRecallStrategy implements RecallStrategy {
+
+    public static final String PUSH_FORM = "video_insight";
+    @Autowired
+    private VideoDemandAnalysisRepository videoDemandAnalysisRepository;
+    @Autowired
+    private FilterService filterService;
+
+    @Override
+    public List<Video> recall(RecallParam param) {
+
+        List<Video> results = new ArrayList<>();
+        Pageable pageable = PageRequest.of(0, 5000);
+        List<Long> videoIds = videoDemandAnalysisRepository.findDistinctVideoId(pageable);
+        FilterParam filterParam = FilterParamFactory.create(param, videoIds);
+
+        FilterResult filterResult = filterService.filter(filterParam);
+
+        if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
+            filterResult.getVideoIds().stream().forEach(vid -> {
+                Video video = new Video();
+                video.setVideoId(vid);
+                video.setRovScore(0);
+                video.setPushFrom(pushFrom());
+                results.add(video);
+            });
+        }
+        return results;
+    }
+
+    @Override
+    public String pushFrom() {
+        return PUSH_FORM;
+    }
+
+
+}