]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7705 add MeasureDao#selectProjectMeasuresOfDeveloper
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 5 Jul 2016 13:01:58 +0000 (15:01 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 7 Jul 2016 15:06:59 +0000 (17:06 +0200)
sonar-db/src/main/java/org/sonar/db/measure/MeasureDao.java
sonar-db/src/main/java/org/sonar/db/measure/MeasureMapper.java
sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml

index ebaaa1042e8089839441154892fffc3a1a3aca92..a50dfb98672a96324734c7667ed070e26df8d2e0 100644 (file)
@@ -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);
   }
index 7a6aa3a34bd1d565c05500b80e21d6d11cf7c267..a1bc7f9448d893da5b94ad40e2d9f49d903b86fb 100644 (file)
  */
 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);
 }
index 26a8278ede016d9f0584e208675cc36a61cf07d7..9ddc76522fd5881d924692bf3c3ed60f457b188c 100644 (file)
       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,