]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20315 update CeQueueDao queries
authorPierre <pierre.guillot@sonarsource.com>
Mon, 25 Sep 2023 15:59:31 +0000 (17:59 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 28 Sep 2023 20:03:12 +0000 (20:03 +0000)
server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeQueueDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeQueueMapper.java
server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml

index e736b5b0b2f16a3fd757d7e994f850312e3977f0..ae73750536b6f7f60e8b91010e5ba43e95029b83 100644 (file)
@@ -25,7 +25,6 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import javax.annotation.Nullable;
-import org.apache.ibatis.session.RowBounds;
 import org.sonar.api.utils.System2;
 import org.sonar.db.Dao;
 import org.sonar.db.DbSession;
@@ -65,10 +64,7 @@ public class CeQueueDao implements Dao {
       return emptyList();
     }
 
-    int offset = (page - 1) * pageSize;
-    int limit = page * pageSize;
-
-    return mapper(dbSession).selectByQueryInDescOrder(query, new RowBounds(offset, limit));
+    return mapper(dbSession).selectByQueryInDescOrder(query, Pagination.forPage(page).andSize(pageSize));
   }
 
   public int countByQuery(DbSession dbSession, CeTaskQuery query) {
index ef578cfc5f29d49985c697ff3c933dd5fdde89e2..f2e6cf0ae05740e73d2f831ee5fba0783e91f4c4 100644 (file)
@@ -24,7 +24,6 @@ import java.util.Optional;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.session.RowBounds;
 import org.sonar.db.Pagination;
 
 public interface CeQueueMapper {
@@ -33,7 +32,7 @@ public interface CeQueueMapper {
 
   List<CeQueueDto> selectAllInAscOrder();
 
-  List<CeQueueDto> selectByQueryInDescOrder(@Param("query") CeTaskQuery query, RowBounds rowBounds);
+  List<CeQueueDto> selectByQueryInDescOrder(@Param("query") CeTaskQuery query, @Param("pagination") Pagination pagination);
 
   int countByQuery(@Param("query") CeTaskQuery query);
 
index 613d709686bf9af7424b77fe4e4cb56713c92b6b..c98190ef5242a217834dd080f8e03eca617c270c 100644 (file)
     <include refid="columns"/>
     <include refid="sqlSelectByQuery"/>
     <include refid="orderByDescDateAndUuid"/>
+    <include refid="pagination"/>
   </select>
 
+  <sql id="pagination">
+    offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+  </sql>
+
   <select id="countByQuery" resultType="int">
     select
       count(1)