]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-23207 Fix telemetry metrics for Cpp autoconfig
authorAlain Kermis <alain.kermis@sonarsource.com>
Fri, 27 Sep 2024 10:13:01 +0000 (12:13 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 30 Sep 2024 14:11:11 +0000 (14:11 +0000)
server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java
server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml
server/sonar-webserver/src/it/java/org/sonar/server/platform/telemetry/ProjectCppAutoconfigTelemetryProviderIT.java

index 6209b00b976aed7fdc66738840254fa33030d87a..3f4003019cfa05f537c5b437d79cd5126a16fe59 100644 (file)
@@ -488,17 +488,17 @@ class ProjectDaoIT {
       .collect(Collectors.toSet());
   }
 
-  private Consumer<LiveMeasureDto> configureLiveMeasure(String language, MetricDto metric, ProjectDto project, ComponentDto componentDto) {
+  private Consumer<LiveMeasureDto> configureLiveMeasure(String language, MetricDto metric, ComponentDto componentDto) {
     return liveMeasure -> liveMeasure
       .setMetricUuid(metric.getUuid())
       .setComponentUuid(componentDto.uuid())
-      .setProjectUuid(project.getUuid())
+      .setProjectUuid(componentDto.uuid())
       .setData(language + "=" + random.nextInt(10));
   }
 
   private Consumer<ProjectData> insertLiveMeasure(String language, MetricDto metric) {
     return (projectData) -> db.measures().insertLiveMeasure(projectData.getMainBranchComponent(), metric,
-      configureLiveMeasure(language, metric, projectData.getProjectDto(), projectData.getMainBranchComponent()));
+      configureLiveMeasure(language, metric, projectData.getMainBranchComponent()));
   }
 
   private void insertProjectsLiveMeasures(String language, Set<ProjectData> projects) {
index abfd58f2f88ba01abae91381f45d5dab2063d968..575a4356117e3e2c4587478eebb075faa2e849f7 100644 (file)
 
   <select id="selectProjectUuidsAssociatedToDefaultQualityProfileByLanguage" parameterType="map" resultType="string">
     select
-      lm.project_uuid
+      p.uuid
     from
       live_measures lm
     inner join
-      projects p on p.uuid = lm.project_uuid
+      project_branches pb on pb.uuid = lm.component_uuid
     inner join
-      metrics m on m.uuid = lm.metric_uuid
+      projects p on p.uuid = pb.project_uuid
     inner join
-      project_branches pb on pb.uuid = lm.component_uuid
+      metrics m on m.uuid = lm.metric_uuid
     where
       m.name = 'ncloc_language_distribution'
       and pb.is_main = ${_true}
     from
       live_measures lm
     inner join
-      projects p on p.uuid = lm.project_uuid
+      project_branches pb on pb.uuid = lm.project_uuid and pb.is_main = ${_true}
+    inner join
+      projects p on p.uuid = pb.project_uuid
     inner join
       metrics m on m.uuid = lm.metric_uuid
     where
index 3ad5a8f3d6ac6075a86a648f62684283cbc2a5ff..56dcbd731b1aa46a0cd748b4b35b806f687a237b 100644 (file)
@@ -123,16 +123,16 @@ class ProjectCppAutoconfigTelemetryProviderIT {
       );
   }
 
-  private Consumer<LiveMeasureDto> configureLiveMeasure(String language, MetricDto metric, ProjectDto project, ComponentDto componentDto) {
+  private Consumer<LiveMeasureDto> configureLiveMeasure(String language, MetricDto metric, ComponentDto componentDto) {
     return liveMeasure -> liveMeasure
       .setMetricUuid(metric.getUuid())
       .setComponentUuid(componentDto.uuid())
-      .setProjectUuid(project.getUuid())
+      .setProjectUuid(componentDto.uuid())
       .setData(language + "=" + 100);
   }
 
   private Consumer<ProjectData> insertLiveMeasure(String language, MetricDto metric) {
     return projectData -> db.measures().insertLiveMeasure(projectData.getMainBranchComponent(), metric,
-      configureLiveMeasure(language, metric, projectData.getProjectDto(), projectData.getMainBranchComponent()));
+      configureLiveMeasure(language, metric, projectData.getMainBranchComponent()));
   }
 }