]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17195 Use "devopsPlatform" field name instead "alm" in telemetry
authorJacek <jacek.poreda@sonarsource.com>
Tue, 27 Sep 2022 12:04:38 +0000 (14:04 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 28 Sep 2022 20:04:08 +0000 (20:04 +0000)
server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java
server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java
server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java
server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java
server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java

index 3f498118e9ecf47f40157a7fcdc76a2682d7d528..1f4cd508c6dfdf52b5e1a98e69bcb3451445bb7b 100644 (file)
@@ -303,15 +303,15 @@ public class TelemetryData {
     private final Long pullRequestCount;
     private final String scm;
     private final String ci;
-    private final String alm;
+    private final String devopsPlatform;
 
-    ProjectStatistics(String projectUuid, Long branchCount, Long pullRequestCount, @Nullable String scm, @Nullable String ci, @Nullable String alm) {
+    ProjectStatistics(String projectUuid, Long branchCount, Long pullRequestCount, @Nullable String scm, @Nullable String ci, @Nullable String devopsPlatform) {
       this.projectUuid = projectUuid;
       this.branchCount = branchCount;
       this.pullRequestCount = pullRequestCount;
       this.scm = scm;
       this.ci = ci;
-      this.alm = alm;
+      this.devopsPlatform = devopsPlatform;
     }
 
     public String getProjectUuid() {
@@ -337,8 +337,8 @@ public class TelemetryData {
     }
 
     @CheckForNull
-    public String getAlm() {
-      return alm;
+    public String getDevopsPlatform() {
+      return devopsPlatform;
     }
   }
 }
index e8e6e186687fb18a07441cea833f16c88cacb081..3bd3dda66e446b81db12d36f2802c43ebc3792ae 100644 (file)
@@ -135,7 +135,7 @@ public class TelemetryDataJsonWriter {
         json.prop("pullRequestCount", project.getPullRequestCount());
         json.prop("scm", project.getScm());
         json.prop("ci", project.getCi());
-        json.prop("alm", project.getAlm());
+        json.prop("devopsPlatform", project.getDevopsPlatform());
         json.endObject();
       });
       json.endArray();
index 31b5edd4601a778eb3243a9fd9f1637c3b07c5d9..8782cd1863b6fab062621d7e527e81b93ad80052 100644 (file)
@@ -348,7 +348,7 @@ public class TelemetryDataJsonWriterTest {
       "      \"pullRequestCount\": 2," +
       "      \"scm\": \"scm-0\"," +
       "      \"ci\": \"ci-0\"," +
-      "      \"alm\": \"alm-0\"" +
+      "      \"devopsPlatform\": \"devops-0\"" +
       "    }," +
       "    {" +
       "      \"projectUuid\": \"uuid-1\"," +
@@ -356,7 +356,7 @@ public class TelemetryDataJsonWriterTest {
       "      \"pullRequestCount\": 4," +
       "      \"scm\": \"scm-1\"," +
       "      \"ci\": \"ci-1\"," +
-      "      \"alm\": \"alm-1\"" +
+      "      \"devopsPlatform\": \"devops-1\"" +
       "    }," +
       "    {" +
       "      \"projectUuid\": \"uuid-2\"," +
@@ -364,7 +364,7 @@ public class TelemetryDataJsonWriterTest {
       "      \"pullRequestCount\": 6," +
       "      \"scm\": \"scm-2\"," +
       "      \"ci\": \"ci-2\"," +
-      "      \"alm\": \"alm-2\"" +
+      "      \"devopsPlatform\": \"devops-2\"" +
       "    }" +
       "  ]" +
       "}");
@@ -381,7 +381,7 @@ public class TelemetryDataJsonWriterTest {
   }
 
   private List<TelemetryData.ProjectStatistics> getProjectStats() {
-    return IntStream.range(0, 3).mapToObj(i -> new TelemetryData.ProjectStatistics("uuid-" + i, (i + 1L) * 2L, (i + 1L) * 2L, "scm-" + i, "ci-" + i, "alm-" + i))
+    return IntStream.range(0, 3).mapToObj(i -> new TelemetryData.ProjectStatistics("uuid-" + i, (i + 1L) * 2L, (i + 1L) * 2L, "scm-" + i, "ci-" + i, "devops-" + i))
       .collect(Collectors.toList());
   }
 
index 9952ad298c3c6f63870e229157ecbf8ab23a405a..8a91caa450572ec444d38a60e681c93e20034592 100644 (file)
@@ -45,7 +45,6 @@ import org.sonar.db.alm.setting.ProjectAlmKeyAndProject;
 import org.sonar.db.component.AnalysisPropertyValuePerProject;
 import org.sonar.db.component.PrAndBranchCountByProjectDto;
 import org.sonar.db.measure.ProjectMeasureDto;
-import org.sonar.server.measure.index.ProjectMeasuresIndex;
 import org.sonar.server.platform.DockerSupport;
 import org.sonar.server.property.InternalProperties;
 import org.sonar.server.telemetry.TelemetryData.Database;
@@ -138,14 +137,14 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader {
         Long pullRequestCount = Optional.ofNullable(prAndBranchCountByProjects.get(projectUuid)).map(PrAndBranchCountByProjectDto::getPullRequest).orElse(0L);
         String scm = Optional.ofNullable(scmByProject.get(projectUuid)).orElse(UNDETECTED);
         String ci = Optional.ofNullable(ciByProject.get(projectUuid)).orElse(UNDETECTED);
-        String alm = null;
+        String devopsPlatform = null;
         if (almAndUrlByProject.containsKey(projectUuid)) {
           ProjectAlmKeyAndProject projectAlmKeyAndProject = almAndUrlByProject.get(projectUuid);
-          alm = getAlmName(projectAlmKeyAndProject.getAlmId(), projectAlmKeyAndProject.getUrl());
+          devopsPlatform = getAlmName(projectAlmKeyAndProject.getAlmId(), projectAlmKeyAndProject.getUrl());
         }
-        alm = Optional.ofNullable(alm).orElse(UNDETECTED);
+        devopsPlatform = Optional.ofNullable(devopsPlatform).orElse(UNDETECTED);
 
-        projectStatistics.add(new TelemetryData.ProjectStatistics(projectUuid, branchCount, pullRequestCount, scm, ci, alm));
+        projectStatistics.add(new TelemetryData.ProjectStatistics(projectUuid, branchCount, pullRequestCount, scm, ci, devopsPlatform));
       }
       data.setProjectStatistics(projectStatistics);
 
index ab59d5c08039855c3077afb89890371b53725f87..b4fa868a8dfbefbb35d15fedec96379e8a38df1d 100644 (file)
@@ -41,9 +41,6 @@ import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.metric.MetricDto;
 import org.sonar.db.user.UserDto;
 import org.sonar.db.user.UserTelemetryDto;
-import org.sonar.server.es.EsTester;
-import org.sonar.server.measure.index.ProjectMeasuresIndex;
-import org.sonar.server.measure.index.ProjectMeasuresIndexer;
 import org.sonar.server.platform.DockerSupport;
 import org.sonar.server.property.InternalProperties;
 import org.sonar.server.property.MapInternalProperties;
@@ -176,7 +173,7 @@ public class TelemetryDataLoaderImplTest {
         tuple(project2.uuid(), "js", 20L, analysisDate));
     assertThat(data.getProjectStatistics())
       .extracting(TelemetryData.ProjectStatistics::getBranchCount, TelemetryData.ProjectStatistics::getPullRequestCount,
-        TelemetryData.ProjectStatistics::getScm, TelemetryData.ProjectStatistics::getCi, TelemetryData.ProjectStatistics::getAlm)
+        TelemetryData.ProjectStatistics::getScm, TelemetryData.ProjectStatistics::getCi, TelemetryData.ProjectStatistics::getDevopsPlatform)
       .containsExactlyInAnyOrder(
         tuple(1L, 0L, "scm-1", "ci-1", "azure_devops_cloud"),
         tuple(1L, 0L, "scm-2", "ci-2", "github_cloud"));
@@ -386,7 +383,7 @@ public class TelemetryDataLoaderImplTest {
     db.components().insertPublicProject();
     TelemetryData data = communityUnderTest.load();
     assertThat(data.getProjectStatistics())
-      .extracting(TelemetryData.ProjectStatistics::getAlm, TelemetryData.ProjectStatistics::getScm, TelemetryData.ProjectStatistics::getCi)
+      .extracting(TelemetryData.ProjectStatistics::getDevopsPlatform, TelemetryData.ProjectStatistics::getScm, TelemetryData.ProjectStatistics::getCi)
       .containsExactlyInAnyOrder(tuple("undetected", "undetected", "undetected"));
   }