aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
authorOrlovAlexander <alexander.orlov@sonarsource.com>2024-12-10 11:02:07 +0100
committerSteve Marion <steve.marion@sonarsource.com>2024-12-18 11:13:21 +0100
commitd0ace9eba4fcb4e79eb10a57f1f596e4237702f7 (patch)
tree3dbaafb122219407d233a2dbda5850222dae45e5 /server/sonar-db-dao
parentbd488052eb3e86a10cdc9c4c10f2ec51d6a97856 (diff)
downloadsonarqube-d0ace9eba4fcb4e79eb10a57f1f596e4237702f7.tar.gz
sonarqube-d0ace9eba4fcb4e79eb10a57f1f596e4237702f7.zip
SONAR-23734 Total number of applications Telemetry
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java10
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDao.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectMapper.java2
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml6
4 files changed, 22 insertions, 0 deletions
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java
index 51d0f300426..b44d0d98d08 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java
@@ -490,6 +490,16 @@ class ProjectDaoIT {
}
@Test
+ void countApplications_shouldReturn_correctValue() {
+ assertThat(projectDao.countProjects(db.getSession())).isZero();
+
+ IntStream.range(0, 3).forEach(x -> db.components().insertPrivateProject());
+ IntStream.range(0, 5).forEach(x -> db.components().insertPrivateApplication());
+
+ assertThat(projectDao.countApplications(db.getSession())).isEqualTo(5);
+ }
+
+ @Test
void countProjects_by_ai_codefix_enablement() {
var dto1 = createProject("o1", "p1").setAiCodeFixEnabled(true);
var dto2 = createProject("o1", "p2");
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDao.java
index 40ff12f7d9e..78544955364 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDao.java
@@ -160,6 +160,10 @@ public class ProjectDao implements Dao {
return mapper(session).countProjects();
}
+ public int countApplications(DbSession session) {
+ return mapper(session).countApplications();
+ }
+
public int countAiCodeFixEnabledProjects(DbSession session) {
return mapper(session).countProjectsByAiCodeFixEnablement(true);
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectMapper.java
index fff27584ee6..d0047c9a2cc 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectMapper.java
@@ -78,5 +78,7 @@ public interface ProjectMapper {
int countProjects();
+ int countApplications();
+
int countProjectsByAiCodeFixEnablement(@Param("aiCodeFixEnabled") boolean aiCodeFixEnabled);
}
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml
index fa11cb1353c..d8818c409d5 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml
@@ -226,6 +226,12 @@
where p.qualifier = 'TRK'
</select>
+ <select id="countApplications" resultType="int">
+ select count(p.uuid)
+ from projects p
+ where p.qualifier = 'APP'
+ </select>
+
<select id="countProjectsByAiCodeFixEnablement" resultType="int">
select count(p.uuid)
from projects p