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;
}
public Optional<SnapshotDto> 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();
}
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 {
List<SnapshotDto> selectSnapshotsByQuery(@Param("query") SnapshotQuery query);
- List<SnapshotDto> selectOldestSnapshots(@Param("rootComponentUuid") String rootComponentUuid, @Param("status") String status, RowBounds rowBounds);
+ List<SnapshotDto> selectOldestSnapshots(@Param("rootComponentUuid") String rootComponentUuid, @Param("status") String status, @Param("pagination") Pagination pagination);
List<ViewsSnapshotDto> selectSnapshotBefore(@Param("rootComponentUuid") String rootComponentUuid, @Param("date") long date);
and s.status = #{status,jdbcType=VARCHAR}
</where>
ORDER BY s.created_at ASC
+ <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="selectSnapshotBefore" resultType="ViewsSnapshot">
SELECT
<include refid="viewsSnapshotColumns" />