]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6834 fix SQL request to count activities
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 25 Sep 2015 15:29:03 +0000 (17:29 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 25 Sep 2015 15:29:15 +0000 (17:29 +0200)
when there are more than one condition

sonar-db/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml
sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java

index 44502db6dfbf61746323f3b0e8afc42d3e23604a..0b6090577a8300d482abf983445a686e3c2f0d14 100644 (file)
     from ce_activity ca
     <where>
       <if test="query.onlyCurrents">
-        ca.is_last=${_true}
+        and ca.is_last=${_true}
       </if>
       <if test="query.componentUuid != null">
-        ca.component_uuid=#{query.componentUuid}
+        and ca.component_uuid=#{query.componentUuid}
       </if>
       <if test="query.status != null">
-        ca.status=#{query.status}
+        and ca.status=#{query.status}
       </if>
       <if test="query.type != null">
-        ca.task_type=#{query.type}
+        and ca.task_type=#{query.type}
       </if>
     </where>
   </select>
index 1323435fcdcda0c5429de6ded07bffb7c728dcd2..e9830ab9b9b2bf0207f0493b8b81b6deaa83ac6b 100644 (file)
@@ -139,6 +139,10 @@ public class CeActivityDaoTest {
     assertThat(underTest.countByQuery(db.getSession(), query)).isEqualTo(3);
     query = new CeActivityQuery().setType("views");
     assertThat(underTest.countByQuery(db.getSession(), query)).isEqualTo(1);
+
+    // select by multiple conditions
+    query = new CeActivityQuery().setType(REPORT).setOnlyCurrents(true).setComponentUuid("PROJECT_1");
+    assertThat(underTest.countByQuery(db.getSession(), query)).isEqualTo(1);
   }
 
   @Test