]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16501 'projectCountBySCM' and 'projectCountByCI' count branches as projects
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 21 Jun 2022 18:32:16 +0000 (13:32 -0500)
committersonartech <sonartech@sonarsource.com>
Wed, 22 Jun 2022 16:09:14 +0000 (16:09 +0000)
server/sonar-db-dao/src/main/resources/org/sonar/db/component/AnalysisPropertiesMapper.xml
server/sonar-db-dao/src/test/java/org/sonar/db/component/AnalysisPropertiesDaoTest.java

index 685e1ad0a0582e0b38e36df3b532e34ae5ee989e..846ae7a2338fdeb0cbb176ae82bdcdbb25bbdfe5 100644 (file)
@@ -39,7 +39,7 @@
     inner join snapshots s on s.component_uuid = cp.uuid
     inner join analysis_properties ap on ap.analysis_uuid = s.uuid
     where
-      s.islast = ${_true} and ap.kee = #{analysisPropertyKey, jdbcType=VARCHAR}
+      cp.main_branch_project_uuid is null and s.islast = ${_true} and ap.kee = #{analysisPropertyKey, jdbcType=VARCHAR}
     group by ap.text_value
   </select>
 
index 2b74ed3d1796db9108ccea74aac35e8a4a332765..852291698aa2f0cbb7770e5b4e6315678cdd4030 100644 (file)
@@ -184,7 +184,10 @@ public class AnalysisPropertiesDaoTest {
       final int index = i;
       ProjectDto project = dbTester.components().insertPrivateProjectDto();
       dbTester.components().insertSnapshot(project, s -> s.setLast(true).setUuid("uuid" + index));
+      // branches shouldn't be taken into account
+      dbTester.components().insertProjectBranch(project);
     }
+
     underTest.insert(dbSession, new AnalysisPropertyDto().setKey(analysisPropertyKey).setValue("git").setAnalysisUuid("uuid0").setUuid("0"));
     underTest.insert(dbSession, new AnalysisPropertyDto().setKey(analysisPropertyKey).setValue("svn").setAnalysisUuid("uuid1").setUuid("1"));
     underTest.insert(dbSession, new AnalysisPropertyDto().setKey(analysisPropertyKey).setValue("undetected").setAnalysisUuid("uuid2").setUuid("2"));