DI - Add metric name in group name (#18634)

This commit is contained in:
Mayur Singal 2024-11-14 10:50:19 +05:30 committed by GitHub
parent 7aae60b760
commit 14643f2b50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 6 deletions

View File

@ -317,7 +317,8 @@ public interface ElasticSearchDynamicChartAggregatorInterface {
return new DataInsightCustomChartResult()
.withCount(value)
.withDay(Double.valueOf(key))
.withGroup(group);
.withGroup(group)
.withMetric(metric);
return new DataInsightCustomChartResult()
.withCount(value)
.withGroup(group)

View File

@ -145,11 +145,17 @@ public class ElasticSearchLineChartAggregator
ParsedTerms parsedTerms = (ParsedTerms) arg;
for (Terms.Bucket bucket : parsedTerms.getBuckets()) {
for (Aggregation subArg : bucket.getAggregations()) {
String group;
if (lineChart.getMetrics().size() > 1) {
group = bucket.getKeyAsString() + " - " + getMetricName(lineChart, subArg.getName());
} else {
group = bucket.getKeyAsString();
}
diChartResults.addAll(
processAggregations(
List.of(subArg),
metricFormulaHolderInternal.get(subArg.getName()).formula,
bucket.getKeyAsString(),
group,
metricFormulaHolderInternal.get(subArg.getName()).holders,
getMetricName(lineChart, subArg.getName())));
}
@ -165,11 +171,15 @@ public class ElasticSearchLineChartAggregator
metricFormulaHolder.get(aggregationList.get(i).getName()) == null
? new MetricFormulaHolder()
: metricFormulaHolderInternal.get(aggregationList.get(i).getName());
String group = null;
if (lineChart.getMetrics().size() > 1) {
group = getMetricName(lineChart, aggregationList.get(i).getName());
}
List<DataInsightCustomChartResult> results =
processAggregations(
List.of(aggregationList.get(i)),
formulaHolder.formula,
null,
group,
formulaHolder.holders,
getMetricName(lineChart, aggregationList.get(i).getName()));
diChartResults.addAll(results);

View File

@ -316,7 +316,8 @@ public interface OpenSearchDynamicChartAggregatorInterface {
return new DataInsightCustomChartResult()
.withCount(value)
.withDay(Double.valueOf(key))
.withGroup(group);
.withGroup(group)
.withMetric(metric);
return new DataInsightCustomChartResult()
.withCount(value)
.withGroup(group)

View File

@ -144,11 +144,17 @@ public class OpenSearchLineChartAggregator implements OpenSearchDynamicChartAggr
ParsedTerms parsedTerms = (ParsedTerms) arg;
for (Terms.Bucket bucket : parsedTerms.getBuckets()) {
for (Aggregation subArg : bucket.getAggregations()) {
String group;
if (lineChart.getMetrics().size() > 1) {
group = bucket.getKeyAsString() + " - " + getMetricName(lineChart, subArg.getName());
} else {
group = bucket.getKeyAsString();
}
diChartResults.addAll(
processAggregations(
List.of(subArg),
metricFormulaHolderInternal.get(subArg.getName()).formula,
bucket.getKeyAsString(),
group,
metricFormulaHolderInternal.get(subArg.getName()).holders,
getMetricName(lineChart, subArg.getName())));
}
@ -164,11 +170,15 @@ public class OpenSearchLineChartAggregator implements OpenSearchDynamicChartAggr
metricFormulaHolderInternal.get(aggregationList.get(i).getName()) == null
? new MetricFormulaHolder()
: metricFormulaHolderInternal.get(aggregationList.get(i).getName());
String group = null;
if (lineChart.getMetrics().size() > 1) {
group = getMetricName(lineChart, aggregationList.get(i).getName());
}
List<DataInsightCustomChartResult> results =
processAggregations(
List.of(aggregationList.get(i)),
formulaHolder.formula,
null,
group,
formulaHolder.holders,
getMetricName(lineChart, aggregationList.get(i).getName()));
diChartResults.addAll(results);