aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-09-25 17:29:03 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-09-25 17:29:15 +0200
commit4cd5fa93ab29252ec587898c23b1855c4359776b (patch)
tree69572c727b947be7de0115bd00fbc5bd03c44a33 /sonar-db
parent78db746ae7e20eb1ae3bb38893cbe23cac845a19 (diff)
downloadsonarqube-4cd5fa93ab29252ec587898c23b1855c4359776b.tar.gz
sonarqube-4cd5fa93ab29252ec587898c23b1855c4359776b.zip
SONAR-6834 fix SQL request to count activities
when there are more than one condition
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml8
-rw-r--r--sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java4
2 files changed, 8 insertions, 4 deletions
diff --git a/sonar-db/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml b/sonar-db/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml
index 44502db6dfb..0b6090577a8 100644
--- a/sonar-db/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml
@@ -67,16 +67,16 @@
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>
diff --git a/sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java b/sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java
index 1323435fcdc..e9830ab9b9b 100644
--- a/sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java
@@ -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