aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/measure/db/MeasureMapper.java5
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml16
2 files changed, 21 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureMapper.java b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureMapper.java
index 6752fe6f6b3..572d70715cd 100644
--- a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureMapper.java
@@ -22,6 +22,8 @@ package org.sonar.core.measure.db;
import org.apache.ibatis.annotations.Param;
+import javax.annotation.CheckForNull;
+
import java.util.List;
public interface MeasureMapper {
@@ -30,6 +32,9 @@ public interface MeasureMapper {
List<MeasureDto> selectByComponentAndMetrics(@Param("componentKey") String componentKey, @Param("metricKeys") List<String> metricKeys);
+ @CheckForNull
+ MeasureDto selectByComponentAndMetric(@Param("componentKey") String componentKey, @Param("metricKey") String metricKey);
+
long countByKey(@Param("key") MeasureKey key);
}
diff --git a/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml b/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml
index cde157e101f..0964ff196f1 100644
--- a/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml
@@ -50,6 +50,22 @@
</where>
</select>
+ <select id="selectByComponentAndMetric" parameterType="map" resultType="Measure">
+ SELECT metric.name as metric_name,
+ <include refid="measureColumns"/>
+ FROM project_measures pm
+ INNER JOIN snapshots s ON s.id=pm.snapshot_id AND s.islast=${_true}
+ INNER JOIN projects p ON p.id=s.project_id AND p.enabled=${_true}
+ INNER JOIN metrics metric ON metric.id=pm.metric_id
+ <where>
+ AND p.kee = #{componentKey}
+ AND metric.name=#{metricKey}
+ AND pm.rule_id IS NULL
+ AND pm.characteristic_id IS NULL
+ AND pm.person_id IS NULL
+ </where>
+ </select>
+
<select id="countByKey" parameterType="map" resultType="long">
SELECT count(pm.id)
FROM project_measures pm