[improvement][headless]Update the model without updating the names of metrics and dimensions. (#1999)
Some checks are pending
supersonic CentOS CI / build (21) (push) Waiting to run
supersonic mac CI / build (21) (push) Waiting to run
supersonic ubuntu CI / build (21) (push) Waiting to run
supersonic windows CI / build (21) (push) Waiting to run

This commit is contained in:
czeeland
2025-01-08 16:25:58 +08:00
committed by GitHub
parent 4e653c1fb1
commit ab74acc84a
2 changed files with 26 additions and 6 deletions

View File

@@ -465,10 +465,11 @@ public class DimensionServiceImpl extends ServiceImpl<DimensionDOMapper, Dimensi
}
private boolean isChange(DimensionReq dimensionReq, DimensionResp dimensionResp) {
boolean isNameChange = !dimensionReq.getName().equals(dimensionResp.getName());
boolean isExtChange = !new EqualsBuilder()
.append(dimensionReq.getExt(), dimensionResp.getExt()).isEquals();
boolean isTypeParamChange =
!Objects.equals(dimensionReq.getTypeParams(), dimensionResp.getTypeParams());
return isExtChange || isTypeParamChange;
return isNameChange || isExtChange || isTypeParamChange;
}
}

View File

@@ -96,11 +96,25 @@ public class MetricServiceImpl extends ServiceImpl<MetricDOMapper, MetricDO>
.collect(Collectors.toMap(MetricResp::getBizName, a -> a, (k1, k2) -> k1));
Map<String, MetricResp> nameMap = metricResps.stream()
.collect(Collectors.toMap(MetricResp::getName, a -> a, (k1, k2) -> k1));
List<MetricReq> metricToInsert =
metricReqs.stream()
.filter(metric -> !bizNameMap.containsKey(metric.getBizName())
&& !nameMap.containsKey(metric.getName()))
.collect(Collectors.toList());
List<MetricReq> metricToInsert = Lists.newArrayList();
metricReqs.stream().forEach(metric -> {
if (!bizNameMap.containsKey(metric.getBizName())
&& !nameMap.containsKey(metric.getName())) {
metricToInsert.add(metric);
} else {
MetricResp metricRespByBizName = bizNameMap.get(metric.getBizName());
MetricResp metricRespByName = nameMap.get(metric.getName());
if (null != metricRespByBizName && isChange(metric, metricRespByBizName)) {
metric.setId(metricRespByBizName.getId());
this.updateMetric(metric, user);
} else {
if (null != metricRespByName && isChange(metric, metricRespByName)) {
metric.setId(metricRespByName.getId());
this.updateMetric(metric, user);
}
}
}
});
if (CollectionUtils.isEmpty(metricToInsert)) {
return;
}
@@ -804,4 +818,9 @@ public class MetricServiceImpl extends ServiceImpl<MetricDOMapper, MetricDO>
.getAllModelByDomainIds(Collections.singletonList(queryMetricReq.getDomainId()));
return modelResps.stream().map(ModelResp::getId).collect(Collectors.toSet());
}
private boolean isChange(MetricReq metricReq, MetricResp metricResp) {
boolean isNameChange = !metricReq.getName().equals(metricResp.getName());
return isNameChange;
}
}