From 133d65fa22e3e8fd332fea8411d4f7c30c64e34c Mon Sep 17 00:00:00 2001 From: Zipeng WU Date: Tue, 23 May 2023 10:24:56 +0200 Subject: [PATCH] SONAR-19297 Track new code definition in Telemetry Co-authored-by: Zipeng WU Co-authored-by: Nolwenn Cadic --- .../org/sonar/db/component/BranchDao.java | 4 + .../org/sonar/db/component/BranchMapper.java | 2 + .../db/newcodeperiod/NewCodePeriodDao.java | 3 + .../db/newcodeperiod/NewCodePeriodMapper.java | 2 + .../org/sonar/db/component/BranchMapper.xml | 8 ++ .../db/newcodeperiod/NewCodePeriodMapper.xml | 6 ++ .../sonar/server/telemetry/TelemetryData.java | 67 +++++++++++++ .../telemetry/TelemetryDataJsonWriter.java | 41 +++++++- .../server/telemetry/TelemetryDataLoader.java | 2 + .../TelemetryDataJsonWriterTest.java | 96 ++++++++++++++++++- .../server/telemetry/TelemetryDaemon.java | 1 + .../telemetry/TelemetryDataLoaderImpl.java | 74 +++++++++++++- .../TelemetryDataLoaderImplTest.java | 59 +++++++++--- 13 files changed, 341 insertions(+), 24 deletions(-) diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java index 337a3ec9423..609944cdb6d 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java @@ -198,4 +198,8 @@ public class BranchDao implements Dao { .map(BranchDto::isNeedIssueSync) .orElse(false); } + + public List selectAllBranches(DbSession dbSession) { + return mapper(dbSession).selectAllBranches(); + } } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchMapper.java index 57bd3acd77e..86489d34b07 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchMapper.java @@ -76,4 +76,6 @@ public interface BranchMapper { Optional selectMainBranchByProjectUuid(String projectUuid); List selectMainBranchesByProjectUuids(@Param("projectUuids") Collection projectUuids); + + List selectAllBranches(); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodDao.java index 7b1beabc7d2..f3d680ed095 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodDao.java @@ -112,4 +112,7 @@ public class NewCodePeriodDao implements Dao { return session.getMapper(NewCodePeriodMapper.class); } + public List selectAll(DbSession dbSession) { + return mapper(dbSession).selectAll(); + } } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodMapper.java index b9f90f220c7..ad61af11c51 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodMapper.java @@ -45,4 +45,6 @@ public interface NewCodePeriodMapper { long countByProjectAnalysis(String projectAnalysisUuid); List selectAllByProject(String projectUuid); + + List selectAll(); } diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml index 56d6036d4b0..140e3ecfd2c 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml @@ -100,6 +100,13 @@ + + + + +