@@ -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); | |||
} |
@@ -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); | |||
} |
@@ -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, |