diff options
author | Matteo Mara <matteo.mara@sonarsource.com> | 2022-03-03 11:39:12 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-03-09 20:02:58 +0000 |
commit | cc3c0c7119ed51be19435872903f5090b092d415 (patch) | |
tree | 158d97e45e1d5b7f95930a99a15133e7e9dcc1d6 /server/sonar-db-dao/src/main/java/org/sonar | |
parent | 49a08e401022aacd9895a16ed008cc7a6d35421e (diff) | |
download | sonarqube-cc3c0c7119ed51be19435872903f5090b092d415.tar.gz sonarqube-cc3c0c7119ed51be19435872903f5090b092d415.zip |
SONAR-16075 create DAO method for retrieving biggest branch per project
Diffstat (limited to 'server/sonar-db-dao/src/main/java/org/sonar')
3 files changed, 114 insertions, 1 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LargestBranchNclocDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LargestBranchNclocDto.java new file mode 100644 index 00000000000..ae9728f0359 --- /dev/null +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LargestBranchNclocDto.java @@ -0,0 +1,107 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.measure; + +public class LargestBranchNclocDto { + + private String projectUuid; + private String projectName; + private String projectKey; + private long loc; + private String branchName; + private String branchType; + private long lastAnalysisDate; + + public String getProjectUuid() { + return projectUuid; + } + + public LargestBranchNclocDto setProjectUuid(String projectUuid) { + this.projectUuid = projectUuid; + return this; + } + + public String getProjectName() { + return projectName; + } + + public LargestBranchNclocDto setProjectName(String projectName) { + this.projectName = projectName; + return this; + } + + public String getProjectKey() { + return projectKey; + } + + public LargestBranchNclocDto setProjectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public String getBranchName() { + return branchName; + } + + public LargestBranchNclocDto setBranchName(String branchName) { + this.branchName = branchName; + return this; + } + + public String getBranchType() { + return branchType; + } + + public LargestBranchNclocDto setBranchType(String branchType) { + this.branchType = branchType; + return this; + } + + public long getLoc() { + return loc; + } + + public LargestBranchNclocDto setLoc(long loc) { + this.loc = loc; + return this; + } + + public long getLastAnalysisDate() { + return lastAnalysisDate; + } + + public LargestBranchNclocDto setLastAnalysisDate(long lastAnalysisDate) { + this.lastAnalysisDate = lastAnalysisDate; + return this; + } + + @Override + public String toString() { + return new StringBuilder("ProjectMaxNclocDto{") + .append("projectUuid='").append(projectUuid).append('\'') + .append(", projectName='").append(projectName).append('\'') + .append(", projectKey='").append(projectKey).append('\'') + .append(", loc=").append(loc) + .append(", branchName='").append(branchName).append('\'') + .append(", branchType='").append(branchType).append('\'') + .append(", lastAnalysisDate=").append(lastAnalysisDate) + .append('}').toString(); + } +} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java index feb2d1ec337..3b1659aaa95 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java @@ -102,6 +102,10 @@ public class LiveMeasureDao implements Dao { return ncloc == null ? 0L : ncloc; } + public List<LargestBranchNclocDto> getLargestBranchNclocPerProject(DbSession dbSession) { + return mapper(dbSession).getLargestBranchNclocPerProject(); + } + public long countProjectsHavingMeasure(DbSession dbSession, String metric) { return mapper(dbSession).countProjectsHavingMeasure(metric); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java index ac75f35d9c7..8bf20c4a17d 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java @@ -36,7 +36,7 @@ public interface LiveMeasureMapper { @Param("metricKeys") Collection<String> metricKeys); List<LiveMeasureDto> selectByComponentUuidAndMetricKeys( - @Param("componentUuid")String componentUuid, + @Param("componentUuid") String componentUuid, @Param("metricKeys") Collection<String> metricKeys); void scrollSelectByComponentUuidAndMetricKeys( @@ -59,6 +59,8 @@ public interface LiveMeasureMapper { @Param("private") Boolean privateProject, @Nullable @Param("projectUuidToExclude") String projectUuidToExclude); + List<LargestBranchNclocDto> getLargestBranchNclocPerProject(); + Long countProjectsHavingMeasure( @Param("metric") String metric); |