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