aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-core/src/main
diff options
context:
space:
mode:
authorWojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com>2024-03-27 11:08:42 +0100
committersonartech <sonartech@sonarsource.com>2024-03-27 20:02:41 +0000
commit600f05786a0d75aa14a956630c5a4ac68fdf2aa4 (patch)
tree0aeee226068bc0dfa18827b8e5bfe805f41a5828 /server/sonar-webserver-core/src/main
parent98e79991645ea8b0c6ac9b61a546814b46c10750 (diff)
downloadsonarqube-600f05786a0d75aa14a956630c5a4ac68fdf2aa4.tar.gz
sonarqube-600f05786a0d75aa14a956630c5a4ac68fdf2aa4.zip
SONAR-21818 Add information if project is part of a monorepo to telemetry.
Diffstat (limited to 'server/sonar-webserver-core/src/main')
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java
index 3795b286447..40593143fee 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java
@@ -222,7 +222,7 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader {
this.qualityProfileByProjectAndLanguage.clear();
}
- private void loadNewCodeDefinitions(DbSession dbSession, List<BranchMeasuresDto> branchMeasuresDtos) {
+ private void loadNewCodeDefinitions(DbSession dbSession, List<BranchMeasuresDto> branchMeasuresDtos) {
var branchUuidByKey = branchMeasuresDtos.stream()
.collect(Collectors.toMap(dto -> createBranchUniqueKey(dto.getProjectUuid(), dto.getBranchKey()), BranchMeasuresDto::getBranchUuid));
List<NewCodePeriodDto> newCodePeriodDtos = dbClient.newCodePeriodDao().selectAll(dbSession);
@@ -291,7 +291,7 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader {
private void resolveProjectStatistics(TelemetryData.Builder data, DbSession dbSession, String defaultQualityGateUuid, List<ProjectDto> projects) {
Map<String, String> scmByProject = getAnalysisPropertyByProject(dbSession, SONAR_ANALYSIS_DETECTEDSCM);
Map<String, String> ciByProject = getAnalysisPropertyByProject(dbSession, SONAR_ANALYSIS_DETECTEDCI);
- Map<String, ProjectAlmKeyAndProject> almAndUrlByProject = getAlmAndUrlByProject(dbSession);
+ Map<String, ProjectAlmKeyAndProject> almAndUrlAndMonorepoByProject = getAlmAndUrlByProject(dbSession);
Map<String, PrBranchAnalyzedLanguageCountByProjectDto> prAndBranchCountByProject = dbClient.branchDao().countPrBranchAnalyzedLanguageByProjectUuid(dbSession)
.stream().collect(toMap(PrBranchAnalyzedLanguageCountByProjectDto::getProjectUuid, Function.identity()));
Map<String, String> qgatesByProject = getProjectQgatesMap(dbSession);
@@ -313,7 +313,7 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader {
.setQG(qgatesByProject.getOrDefault(projectUuid, defaultQualityGateUuid))
.setScm(Optional.ofNullable(scmByProject.get(projectUuid)).orElse(UNDETECTED))
.setCi(Optional.ofNullable(ciByProject.get(projectUuid)).orElse(UNDETECTED))
- .setDevops(resolveDevopsPlatform(almAndUrlByProject, projectUuid))
+ .setDevops(resolveDevopsPlatform(almAndUrlAndMonorepoByProject, projectUuid))
.setBugs(metrics.getOrDefault("bugs", null))
.setDevelopmentCost(metrics.getOrDefault("development_cost", null))
.setVulnerabilities(metrics.getOrDefault("vulnerabilities", null))
@@ -322,6 +322,7 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader {
.setNcdId(ncdByProject.getOrDefault(projectUuid, instanceNcd).hashCode())
.setExternalSecurityReportExportedAt(securityReportExportedAtByProjectUuid.get(projectUuid))
.setCreationMethod(project.getCreationMethod())
+ .setMonorepo(resolveMonorepo(almAndUrlAndMonorepoByProject, projectUuid))
.build();
projectStatistics.add(stats);
}
@@ -343,6 +344,12 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader {
return UNDETECTED;
}
+ private static Boolean resolveMonorepo(Map<String, ProjectAlmKeyAndProject> almAndUrlByProject, String projectUuid) {
+ return Optional.ofNullable(almAndUrlByProject.get(projectUuid))
+ .map(ProjectAlmKeyAndProject::getMonorepo)
+ .orElse(false);
+ }
+
private void resolveProjects(TelemetryData.Builder data, DbSession dbSession) {
Map<String, String> metricUuidMap = getNclocMetricUuidMap(dbSession);
String nclocUuid = metricUuidMap.get(NCLOC_KEY);
@@ -413,8 +420,7 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader {
Condition telemetryCondition = new Condition(
metricKey,
fromDbValue(condition.getOperator()),
- condition.getErrorThreshold()
- );
+ condition.getErrorThreshold());
conditionsMap
.computeIfAbsent(qualityGateUuid, k -> new ArrayList<>())