aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/main
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-07-05 15:01:58 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-07-07 17:06:59 +0200
commit5c9080278cd5a8fffbe7997f058361b8bff1ecfd (patch)
tree86652d9b049fc09f8d1fbc1b990cda7b5e1ceb59 /sonar-db/src/main
parenteaf980f97bcc9dd745e52a18a9ef84111a537324 (diff)
downloadsonarqube-5c9080278cd5a8fffbe7997f058361b8bff1ecfd.tar.gz
sonarqube-5c9080278cd5a8fffbe7997f058361b8bff1ecfd.zip
SONAR-7705 add MeasureDao#selectProjectMeasuresOfDeveloper
Diffstat (limited to 'sonar-db/src/main')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/measure/MeasureDao.java23
-rw-r--r--sonar-db/src/main/java/org/sonar/db/measure/MeasureMapper.java7
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml18
3 files changed, 30 insertions, 18 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDao.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDao.java
index ebaaa1042e8..a50dfb98672 100644
--- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDao.java
@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Optional;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
-import org.sonar.db.version.Select;
import static org.sonar.db.DatabaseUtils.executeLargeInputs;
@@ -64,19 +63,6 @@ public class MeasureDao implements Dao {
});
}
- public List<MeasureDto> selectByQuery(DbSession dbSession, MeasureQuery query, Select.RowHandler rowHandler) {
- if (query.returnsEmpty()) {
- return Collections.emptyList();
- }
- if (query.getComponentUuids() == null) {
- return mapper(dbSession).selectByQuery(query, rowHandler);
- }
- return executeLargeInputs(query.getComponentUuids(), componentUuids -> {
- MeasureQuery pageQuery = MeasureQuery.copyWithSubsetOfComponentUuids(query, componentUuids);
- return mapper(dbSession).selectByQuery(pageQuery, rowHandler);
- });
- }
-
public List<PastMeasureDto> selectPastMeasures(DbSession dbSession,
String componentUuid,
String analysisUuid,
@@ -86,6 +72,15 @@ public class MeasureDao implements Dao {
ids -> mapper(dbSession).selectPastMeasures(componentUuid, analysisUuid, ids));
}
+ /**
+ * Used by developer cockpit.
+ */
+ public List<MeasureDto> selectProjectMeasuresOfDeveloper(DbSession dbSession, long developerId, Collection<Integer> metricIds) {
+ return executeLargeInputs(
+ metricIds,
+ ids -> mapper(dbSession).selectProjectMeasuresOfDeveloper(developerId, metricIds));
+ }
+
public void insert(DbSession session, MeasureDto measureDto) {
mapper(session).insert(measureDto);
}
diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureMapper.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureMapper.java
index 7a6aa3a34bd..a1bc7f9448d 100644
--- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureMapper.java
+++ b/sonar-db/src/main/java/org/sonar/db/measure/MeasureMapper.java
@@ -19,18 +19,17 @@
*/
package org.sonar.db.measure;
+import java.util.Collection;
import java.util.List;
import org.apache.ibatis.annotations.Param;
-import org.sonar.db.version.Select;
public interface MeasureMapper {
List<MeasureDto> selectByQuery(@Param("query") MeasureQuery query);
- List<MeasureDto> selectByQuery(@Param("query") MeasureQuery query, Select.RowHandler rowHandler);
-
List<PastMeasureDto> selectPastMeasures(@Param("componentUuid") String componentUuid, @Param("analysisUuid") String analysisUuid, @Param("metricIds") List<Integer> metricIds);
- void insert(MeasureDto measureDto);
+ List<MeasureDto> selectProjectMeasuresOfDeveloper(@Param("developerId") long developerId, @Param("metricIds") Collection<Integer> metricIds);
+ void insert(MeasureDto measureDto);
}
diff --git a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml b/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
index 26a8278ede0..9ddc76522fd 100644
--- a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
@@ -76,6 +76,24 @@
and pm.person_id is null
</select>
+ <select id="selectProjectMeasuresOfDeveloper" parameterType="map" resultType="Measure">
+ SELECT
+ <include refid="measureColumns"/>
+ from
+ project_measures pm, snapshots s, projects p
+ where
+ pm.person_id=#{developerId}
+ and pm.metric_id in
+ <foreach item="metricId" collection="metricIds" open="(" separator="," close=")">
+ #{metricId}
+ </foreach>
+ and s.uuid=pm.analysis_uuid
+ and s.islast=${_true}
+ and p.uuid=pm.component_uuid
+ and p.scope='PRJ'
+ and p.qualifier='TRK'
+ </select>
+
<insert id="insert" parameterType="Measure" useGeneratedKeys="false">
insert into project_measures (
value,