3 Commits ad59c3bdc1 ... 69a10423f4

Author SHA1 Message Date
  sunxy 69a10423f4 Merge branch 'feature/20240521/sunxy/fixShareWidthAndDeep' into pre-master 11 months ago
  sunxy e3a06c7aa3 ADD:ShareDeepAndSort Recall Rank 11 months ago
  qingqu-git 0b91d0e481 Merge branch 'feature_20240516_supeng_supply_ab_v2' of algorithm/recommend-server into master 11 months ago

+ 9 - 7
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/ShareDeepRecallStrategy.java

@@ -56,13 +56,15 @@ public class ShareDeepRecallStrategy implements RecallStrategy {
         FilterResult filterResult = filterService.filter(filterParam);
         List<Video> videosResult = new ArrayList<>();
         if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream().limit(Integer.parseInt(shareDeepRecallStrategyRecallNumberAfterFilter)).forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
+            filterResult.getVideoIds().stream()
+                    .sorted(Comparator.comparingDouble(vid -> videoMap.getOrDefault(vid, 0.0)).reversed())
+                    .limit(Integer.parseInt(shareDeepRecallStrategyRecallNumberAfterFilter)).forEach(vid -> {
+                        Video video = new Video();
+                        video.setVideoId(vid);
+                        video.setAbCode(param.getAbCode());
+                        video.setPushFrom(pushFrom());
+                        videosResult.add(video);
+                    });
         }
         return videosResult;
     }

+ 9 - 7
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/ShareWidthRecallStrategy.java

@@ -56,13 +56,15 @@ public class ShareWidthRecallStrategy implements RecallStrategy {
         FilterResult filterResult = filterService.filter(filterParam);
         List<Video> videosResult = new ArrayList<>();
         if (filterResult != null && CollectionUtils.isNotEmpty(filterResult.getVideoIds())) {
-            filterResult.getVideoIds().stream().limit(Integer.parseInt(shareDeepRecallStrategyRecallNumberAfterFilter)).forEach(vid -> {
-                Video video = new Video();
-                video.setVideoId(vid);
-                video.setAbCode(param.getAbCode());
-                video.setPushFrom(pushFrom());
-                videosResult.add(video);
-            });
+            filterResult.getVideoIds().stream()
+                    .sorted(Comparator.comparingDouble(vid -> videoMap.getOrDefault(vid, 0.0)).reversed())
+                    .limit(Integer.parseInt(shareDeepRecallStrategyRecallNumberAfterFilter)).forEach(vid -> {
+                        Video video = new Video();
+                        video.setVideoId(vid);
+                        video.setAbCode(param.getAbCode());
+                        video.setPushFrom(pushFrom());
+                        videosResult.add(video);
+                    });
         }
         return videosResult;
     }