From: Pierre Date: Mon, 25 Sep 2023 16:05:40 +0000 (+0200) Subject: SONAR-20315 update SnapshotDao queries X-Git-Tag: 10.3.0.82913~324 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7afdd7e69b4bd1d380b74c535b31752df7996ea1;p=sonarqube.git SONAR-20315 update SnapshotDao queries --- diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDao.java index ab07876c85b..745efa8cd30 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDao.java @@ -29,9 +29,9 @@ import java.util.Optional; import java.util.stream.IntStream; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.apache.ibatis.session.RowBounds; import org.sonar.db.Dao; import org.sonar.db.DbSession; +import org.sonar.db.Pagination; import static com.google.common.base.Preconditions.checkArgument; import static java.util.Objects.requireNonNull; @@ -89,7 +89,7 @@ public class SnapshotDao implements Dao { } public Optional selectOldestAnalysis(DbSession session, String rootComponentUuid) { - return mapper(session).selectOldestSnapshots(rootComponentUuid, SnapshotDto.STATUS_PROCESSED, new RowBounds(0, 1)) + return mapper(session).selectOldestSnapshots(rootComponentUuid, SnapshotDto.STATUS_PROCESSED, Pagination.first()) .stream() .findFirst(); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotMapper.java index 7a9e64c2c57..79a4435c416 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotMapper.java @@ -23,7 +23,7 @@ import java.util.Collection; import java.util.List; import javax.annotation.CheckForNull; import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.session.RowBounds; +import org.sonar.db.Pagination; import org.sonar.db.component.SnapshotDao.ProjectUuidFromDatePair; public interface SnapshotMapper { @@ -42,7 +42,7 @@ public interface SnapshotMapper { List selectSnapshotsByQuery(@Param("query") SnapshotQuery query); - List selectOldestSnapshots(@Param("rootComponentUuid") String rootComponentUuid, @Param("status") String status, RowBounds rowBounds); + List selectOldestSnapshots(@Param("rootComponentUuid") String rootComponentUuid, @Param("status") String status, @Param("pagination") Pagination pagination); List selectSnapshotBefore(@Param("rootComponentUuid") String rootComponentUuid, @Param("date") long date); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml index 5a2356a79ab..d66491e315d 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml @@ -184,8 +184,13 @@ and s.status = #{status,jdbcType=VARCHAR} ORDER BY s.created_at ASC + + + offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + +