소스 검색

fix: align scene search rov filter

刘立冬 23 시간 전
부모
커밋
4f0a0a3ae5

+ 5 - 2
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/contentplatform/ext/ContentPlatformDemandVideoMapperExt.java

@@ -71,7 +71,8 @@ public interface ContentPlatformDemandVideoMapperExt {
     List<String> selectDistinctCrowdPackages(@Param("dt") String dt, @Param("channelName") String channelName);
 
     /**
-     * 搜索候选白名单:dt 最新分区下,该入口(channel + 入口维度)demand_strategy IN ('人群需求', '优质相似') 且 rov >= 0.03 的视频行。
+     * 搜索候选白名单:dt 最新分区下,该入口(channel + 入口维度)demand_strategy IN ('人群需求', '优质相似') 的视频行。
+     * 非场景已看视频要求 rov >= demandMinRov;场景已看视频与列表下发一致,要求 rov > 0 且 scene_sum_rov >= priorSceneMinSumRov。
      * crowdSegment == "泛人群" 时翻译成 (NULL OR ''/'-'/'null'),与 selectForRecommend 一致。
      * ORDER BY rov DESC, id ASC,便于上层 putIfAbsent 直接取 max rov 代表行。
      * 小程序投流:crowdSegment=#{crowdPackage},channelLevel3=null
@@ -80,7 +81,9 @@ public interface ContentPlatformDemandVideoMapperExt {
     List<ContentPlatformDemandVideo> selectSearchWhitelist(@Param("dt") String dt,
                                                             @Param("channelName") String channelName,
                                                             @Param("crowdSegment") String crowdSegment,
-                                                            @Param("channelLevel3") String channelLevel3);
+                                                            @Param("channelLevel3") String channelLevel3,
+                                                            @Param("demandMinRov") double demandMinRov,
+                                                            @Param("priorSceneMinSumRov") double priorSceneMinSumRov);
 
     List<ContentPlatformDemandVideo> selectActiveVideos(@Param("dt") String dt);
 

+ 13 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java

@@ -739,6 +739,15 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         return matchExposurePv == null || matchExposurePv > minExposurePv;
     }
 
+    static boolean passesSearchDemandRovFilter(String matchMethod, Double rov, Double sceneSumRov,
+                                               double demandMinRov, double priorSceneMinSumRov) {
+        if (DemandMatchMethodEnum.SCENE.getValue().equals(matchMethod)) {
+            return rov != null && rov > 0
+                    && sceneSumRov != null && sceneSumRov >= priorSceneMinSumRov;
+        }
+        return rov != null && rov >= demandMinRov;
+    }
+
     @Override
     public Page<VideoContentItemVO> getVideoContentList(VideoContentListParam param) {
         ContentPlatformAccount user = LoginUserContext.getUser();
@@ -2029,7 +2038,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         if (!StringUtils.hasText(dt)) return empty;
 
         List<ContentPlatformDemandVideo> whitelist = demandVideoMapperExt.selectSearchWhitelist(
-                dt, ch, isXcx ? crowdPackage : null, isXcx ? null : ghName);
+                dt, ch, isXcx ? crowdPackage : null, isXcx ? null : ghName,
+                demandMinRov, priorSceneMinSumRov);
         if (CollectionUtils.isEmpty(whitelist)) return empty;
 
         // SQL 已 ORDER BY rov DESC,putIfAbsent 即拿到 max rov 代表行(设计意图:与排序键一致)
@@ -2043,6 +2053,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         for (ContentPlatformDemandVideo demand : bestPerVideo.values()) {
             if (demand.getTitle() == null) continue;
             if (!demand.getTitle().toLowerCase().contains(kw)) continue;
+            if (!passesSearchDemandRovFilter(demand.getMatchMethod(), demand.getRov(), demand.getSceneSumRov(),
+                    demandMinRov, priorSceneMinSumRov)) continue;
             VideoContentItemVO vo = buildDemandVideoContentItemVOList(Collections.singletonList(demand)).get(0);
             vo.setSearchSource("keyword");
             vo.setScore(null);

+ 5 - 1
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformDemandVideoMapperExt.xml

@@ -194,7 +194,11 @@
           AND demand_strategy IN ('人群需求', '优质相似')
           AND video_id IS NOT NULL
           AND rov IS NOT NULL
-          AND rov &gt;= 0.03
+          AND (
+              (match_method = '场景已看视频' AND rov &gt; 0 AND scene_sum_rov IS NOT NULL AND scene_sum_rov &gt;= #{priorSceneMinSumRov})
+              OR
+              ((match_method IS NULL OR match_method &lt;&gt; '场景已看视频') AND rov &gt;= #{demandMinRov})
+          )
         <if test="crowdSegment != null and crowdSegment != ''">
             <choose>
                 <when test='crowdSegment == "泛人群"'>

+ 21 - 0
api-module/src/test/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImplExposureFilterTest.java

@@ -1,5 +1,6 @@
 package com.tzld.piaoquan.api.service.contentplatform.impl;
 
+import com.tzld.piaoquan.api.common.enums.contentplatform.DemandMatchMethodEnum;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -41,4 +42,24 @@ public class ContentPlatformPlanServiceImplExposureFilterTest {
         assertTrue(ContentPlatformPlanServiceImpl.passesExposureFilter(2001L, 2000L));
         assertTrue(ContentPlatformPlanServiceImpl.passesExposureFilter(50000L, 2000L));
     }
+
+    /** 搜索命中场景已看视频时,与列表下发一致:不按 rov>=0.03,改用 sceneSumRov>=0.03。 */
+    @Test
+    public void searchSceneVideo_usesSceneSumRovThreshold() {
+        assertTrue(ContentPlatformPlanServiceImpl.passesSearchDemandRovFilter(
+                DemandMatchMethodEnum.SCENE.getValue(), 0.01d, 0.03d, 0.03d, 0.03d));
+        assertFalse(ContentPlatformPlanServiceImpl.passesSearchDemandRovFilter(
+                DemandMatchMethodEnum.SCENE.getValue(), 0.01d, 0.029d, 0.03d, 0.03d));
+        assertFalse(ContentPlatformPlanServiceImpl.passesSearchDemandRovFilter(
+                DemandMatchMethodEnum.SCENE.getValue(), 0d, 0.05d, 0.03d, 0.03d));
+    }
+
+    /** 搜索命中非场景已看视频时,仍沿用 demandMinRov。 */
+    @Test
+    public void searchNonSceneVideo_usesDemandMinRovThreshold() {
+        assertFalse(ContentPlatformPlanServiceImpl.passesSearchDemandRovFilter(
+                DemandMatchMethodEnum.VECTOR_SIMILARITY.getValue(), 0.029d, 0.2d, 0.03d, 0.03d));
+        assertTrue(ContentPlatformPlanServiceImpl.passesSearchDemandRovFilter(
+                DemandMatchMethodEnum.VECTOR_SIMILARITY.getValue(), 0.03d, null, 0.03d, 0.03d));
+    }
 }