From 5c9080278cd5a8fffbe7997f058361b8bff1ecfd Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Tue, 5 Jul 2016 15:01:58 +0200 Subject: [PATCH] SONAR-7705 add MeasureDao#selectProjectMeasuresOfDeveloper --- .../java/org/sonar/db/measure/MeasureDao.java | 23 ++++++++----------- .../org/sonar/db/measure/MeasureMapper.java | 7 +++--- .../org/sonar/db/measure/MeasureMapper.xml | 18 +++++++++++++++ 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 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 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 selectProjectMeasuresOfDeveloper(DbSession dbSession, long developerId, Collection 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 selectByQuery(@Param("query") MeasureQuery query); - List selectByQuery(@Param("query") MeasureQuery query, Select.RowHandler rowHandler); - List selectPastMeasures(@Param("componentUuid") String componentUuid, @Param("analysisUuid") String analysisUuid, @Param("metricIds") List metricIds); - void insert(MeasureDto measureDto); + List selectProjectMeasuresOfDeveloper(@Param("developerId") long developerId, @Param("metricIds") Collection 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 + + insert into project_measures ( value, -- 2.39.5