wangyunpeng 3 місяців тому
батько
коміт
5413e453d9

+ 14 - 12
long-article-recommend-service/src/main/resources/mapper/longArticle/LongArticleBaseMapper.xml

@@ -311,18 +311,20 @@
 
     <select id="getTopContent"
             resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy">
-        select *
-        from datastat_sort_strategy
-        where date_str &lt; #{dateStr}
-          and type = 9
-          and read_rate > 1
-          and view_count > 10000
-          and position in (1, 2)
-          and title not in (select title from article_unsafe_title)
-          and first_level is not null
-          and strategy is not null
-        order by read_rate desc
-        limit 200
+        select dss.*
+        from datastat_sort_strategy dss
+                 join (select title, max(read_rate) as read_rate
+                       from datastat_sort_strategy
+                       where date_str &lt; #{dateStr}
+                         and type = 9
+                         and read_rate > 1
+                         and view_count > 10000
+                         and position in (1, 2)
+                         and title not in (select title from article_unsafe_title)
+                         and first_level is not null
+                         and strategy is not null
+                       GROUP BY title) top on dss.title = top.title and dss.read_rate = top.read_rate
+        limit 100
     </select>
 
 </mapper>