From 59c1b3d49a6f4c43ebfadd1310e7bea52c911a99 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Tue, 19 Jan 2016 16:39:39 +0100 Subject: [PATCH] add MeasureDao.selectProjectMeasuresByDeveloperForMetrics --- .../java/org/sonar/db/measure/MeasureDao.java | 13 ++ .../org/sonar/db/measure/MeasureMapper.java | 3 + .../org/sonar/db/measure/MeasureMapper.xml | 18 ++ .../org/sonar/db/measure/MeasureDaoTest.java | 171 ++++++++++++++---- 4 files changed, 167 insertions(+), 38 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 eb82353aaa2..61c95ebb10c 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 @@ -105,6 +105,9 @@ public class MeasureDao implements Dao { }); } + /** + * Used by plugin Developer Cockpit + */ public List selectBySnapshotIdsAndMetricIds(final DbSession dbSession, List snapshotIds, final List metricIds) { return DatabaseUtils.executeLargeInputs(snapshotIds, new Function, List>() { @Override @@ -115,6 +118,16 @@ public class MeasureDao implements Dao { }); } + /** + * Retrieves all measures associated to a specific developer and to the last snapshot of any project. + * property {@link MeasureDto#componentId} of the returned objects is populated + * + * Used by Developer Cockpit + */ + public List selectProjectMeasuresByDeveloperForMetrics(DbSession dbSession, long developerId, Collection metricIds) { + return mapper(dbSession).selectProjectMeasuresByDeveloperForMetrics(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 996d765c5fd..82bf90bd0f1 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,6 +19,7 @@ */ package org.sonar.db.measure; +import java.util.Collection; import java.util.List; import javax.annotation.CheckForNull; import org.apache.ibatis.annotations.Param; @@ -38,6 +39,8 @@ public interface MeasureMapper { List selectBySnapshotIdsAndMetricIds(@Param("snapshotIds") List snapshotIds, @Param("metricIds") List metricIds); + List selectProjectMeasuresByDeveloperForMetrics(@Param("developerId") long developerId, @Param("metricIds") Collection metricIds); + @CheckForNull MeasureDto selectByComponentAndMetric(@Param("componentKey") String componentKey, @Param("metricKey") String metricKey); 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 ed8a80b3f70..93a1fa7c7d8 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 @@ -112,6 +112,24 @@ + +