.setTotal(paging.total())
.build();
- response.setBaseComponent(componentDtoToWsComponent(data.getBaseComponent()));
+ response.setBaseComponent(
+ componentDtoToWsComponent(
+ data.getBaseComponent(),
+ data.getMeasuresByComponentUuidAndMetric().row(data.getBaseComponent().uuid()),
+ data.getReferenceComponentUuidsById()));
for (ComponentDto componentDto : data.getComponents()) {
response.addComponents(componentDtoToWsComponent(
int componentCount = componentDtosAndTotal.total;
List<MetricDto> metrics = searchMetrics(dbSession, wsRequest);
List<WsMeasures.Period> periods = periodsFromSnapshot(baseSnapshot);
- Table<String, MetricDto, MeasureDto> measuresByComponentUuidAndMetric = searchMeasuresByComponentUuidAndMetric(dbSession, components, metrics, periods);
+ Table<String, MetricDto, MeasureDto> measuresByComponentUuidAndMetric = searchMeasuresByComponentUuidAndMetric(dbSession, baseComponent, baseSnapshot, components, metrics,
+ periods);
components = sortComponents(components, wsRequest, metrics, measuresByComponentUuidAndMetric);
components = paginateComponents(components, componentCount, wsRequest);
return metrics;
}
- private Table<String, MetricDto, MeasureDto> searchMeasuresByComponentUuidAndMetric(DbSession dbSession, List<ComponentDtoWithSnapshotId> components, List<MetricDto> metrics,
+ private Table<String, MetricDto, MeasureDto> searchMeasuresByComponentUuidAndMetric(DbSession dbSession, ComponentDto baseComponent, SnapshotDto baseSnapshot,
+ List<ComponentDtoWithSnapshotId> components, List<MetricDto> metrics,
List<WsMeasures.Period> periods) {
- Map<Long, ComponentDtoWithSnapshotId> componentsBySnapshotId = Maps.uniqueIndex(components, ComponentDtoWithSnapshotIdToSnapshotIdFunction.INSTANCE);
+ Map<Long, ComponentDto> componentsBySnapshotId = new HashMap<>();
+ componentsBySnapshotId.put(baseSnapshot.getId(), baseComponent);
+ for (ComponentDtoWithSnapshotId component : components) {
+ componentsBySnapshotId.put(component.getSnapshotId(), component);
+ }
Map<Integer, MetricDto> metricsById = Maps.uniqueIndex(metrics, MetricDtoFunctions.toId());
List<MeasureDto> measureDtos = dbClient.measureDao().selectBySnapshotIdsAndMetricIds(dbSession,
"id": "project-id",
"key": "MY_PROJECT",
"name": "My Project",
- "qualifier": "TRK"
+ "qualifier": "TRK",
+ "measures": [
+ {
+ "metric": "new_violations",
+ "variationValueP1": "255",
+ "variationValueP2": "0",
+ "variationValueP3": "255"
+ },
+ {
+ "metric": "ncloc",
+ "value": "1984"
+ },
+ {
+ "metric": "complexity",
+ "value": "42"
+ }
+ ]
},
"components": [
{
"measures": [
{
"metric": "new_violations",
- "value": "0",
"variationValueP1": "0",
"variationValueP2": "0",
"variationValueP3": "0"
.setValue(12.0d),
newMeasureDto(complexity, directorySnapshot.getId())
.setValue(35.0d)
- .setVariation(2, 0.0d));
+ .setVariation(2, 0.0d),
+ newMeasureDto(complexity, projectSnapshot.getId())
+ .setValue(42.0d));
MetricDto ncloc = insertNclocMetric();
dbClient.measureDao().insert(dbSession,
.setValue(114.0d),
newMeasureDto(ncloc, directorySnapshot.getId())
.setValue(217.0d)
- .setVariation(2, 0.0d));
+ .setVariation(2, 0.0d),
+ newMeasureDto(ncloc, projectSnapshot.getId())
+ .setValue(1984.0d));
MetricDto newViolations = insertNewViolationsMetric();
dbClient.measureDao().insert(dbSession,
.setVariation(2, 0.0d)
.setVariation(3, 25.0d),
newMeasureDto(newViolations, file2Snapshot.getId())
- .setValue(0.0d)
.setVariation(1, 0.0d)
.setVariation(2, 0.0d)
.setVariation(3, 0.0d),
newMeasureDto(newViolations, directorySnapshot.getId())
.setVariation(1, 25.0d)
.setVariation(2, 0.0d)
- .setVariation(3, 25.0d));
+ .setVariation(3, 25.0d),
+ newMeasureDto(newViolations, projectSnapshot.getId())
+ .setVariation(1, 255.0d)
+ .setVariation(2, 0.0d)
+ .setVariation(3, 255.0d));
db.commit();
}