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() return new DataInsightCustomChartResult()
.withCount(value) .withCount(value)
.withDay(Double.valueOf(key)) .withDay(Double.valueOf(key))
.withGroup(group); .withGroup(group)
.withMetric(metric);
return new DataInsightCustomChartResult() return new DataInsightCustomChartResult()
.withCount(value) .withCount(value)
.withGroup(group) .withGroup(group)

View File

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

View File

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

View File

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