diff options
author | Lukasz Jarocki <lukasz.jarocki@sonarsource.com> | 2021-12-10 10:26:07 +0100 |
---|---|---|
committer | Lukasz Jarocki <lukasz.jarocki@sonarsource.com> | 2021-12-13 15:22:58 +0100 |
commit | 0d0b7e4ff71957681e868404f87a526314f89181 (patch) | |
tree | 7a404c2e87183a90b3ee716c4874a21d798c6879 /server/sonar-db-dao/src | |
parent | 38d139582c17354e22e54ea03a73213cd87ca87d (diff) | |
download | sonarqube-0d0b7e4ff71957681e868404f87a526314f89181.tar.gz sonarqube-0d0b7e4ff71957681e868404f87a526314f89181.zip |
SONAR-15770 added compute engine metrics
Diffstat (limited to 'server/sonar-db-dao/src')
4 files changed, 25 insertions, 0 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java index 613f000eb6d..0ebd518ff56 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java @@ -61,6 +61,10 @@ public class CeActivityDao implements Dao { return mapper(dbSession).selectOlderThan(beforeDate); } + public List<CeActivityDto> selectNewerThan(DbSession dbSession, long beforeDate) { + return mapper(dbSession).selectNewerThan(beforeDate); + } + public List<CeActivityDto> selectByTaskType(DbSession dbSession, String taskType) { return mapper(dbSession).selectByTaskType(taskType); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityMapper.java index b6a2a00c1cb..f4e95203874 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityMapper.java @@ -34,6 +34,8 @@ public interface CeActivityMapper { List<CeActivityDto> selectOlderThan(@Param("beforeDate") long beforeDate); + List<CeActivityDto> selectNewerThan(@Param("afterDate") long afterDate); + int countLastByStatusAndMainComponentUuid(@Param("status") CeActivityDto.Status status, @Nullable @Param("mainComponentUuid") String mainComponentUuid); void insert(CeActivityDto dto); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml index 17c222152dd..f94c83b5ffc 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml @@ -143,6 +143,15 @@ where ca.created_at < #{beforeDate,jdbcType=BIGINT} </select> + + <select id="selectNewerThan" parameterType="long" resultType="org.sonar.db.ce.CeActivityDto"> + select + <include refid="columns"/> + from ce_activity ca + left outer join ce_scanner_context csc on csc.task_uuid = ca.uuid + where + ca.created_at > #{afterDate,jdbcType=BIGINT} + </select> <select id="countLastByStatusAndMainComponentUuid" resultType="int"> select diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java index cca5ec95293..6916d6ba297 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java @@ -647,6 +647,16 @@ public class CeActivityDaoTest { } @Test + public void selectNewerThan() { + insertWithCreationDate("TASK_1", 1_450_000_000_000L); + insertWithCreationDate("TASK_2", 1_460_000_000_000L); + insertWithCreationDate("TASK_3", 1_470_000_000_000L); + + List<CeActivityDto> dtos = underTest.selectNewerThan(db.getSession(), 1_455_000_000_000L); + assertThat(dtos).extracting("uuid").containsOnly("TASK_2", "TASK_3"); + } + + @Test public void selectOlder_populates_hasScannerContext_flag() { insertWithCreationDate("TASK_1", 1_450_000_000_000L); CeActivityDto dto2 = insertWithCreationDate("TASK_2", 1_450_000_000_000L); |