mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix matrics comparison to know when to refresh (#26382)
This commit is contained in:
parent
f9239a4d6c
commit
85f3a999f3
@ -15,6 +15,7 @@ export class ElasticQueryCtrl extends QueryCtrl {
|
|||||||
|
|
||||||
esVersion: any;
|
esVersion: any;
|
||||||
rawQueryOld: string;
|
rawQueryOld: string;
|
||||||
|
targetMetricsOld: string;
|
||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
||||||
constructor(
|
constructor(
|
||||||
@ -51,18 +52,17 @@ export class ElasticQueryCtrl extends QueryCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
queryUpdated() {
|
queryUpdated() {
|
||||||
// As Raw Data and Raw Document have the same request, we need to run refresh if they are updated
|
const newJsonTargetMetrics = angular.toJson(this.target.metrics);
|
||||||
const isPossiblyRawDataSwitch = this.target.metrics.some(
|
const newJsonRawQuery = angular.toJson(this.datasource.queryBuilder.build(this.target), true);
|
||||||
(metric: any) => metric.type === 'raw_data' || metric.type === 'raw_document'
|
if (
|
||||||
);
|
(this.rawQueryOld && newJsonRawQuery !== this.rawQueryOld) ||
|
||||||
const newJson = angular.toJson(this.datasource.queryBuilder.build(this.target), true);
|
(this.targetMetricsOld && newJsonTargetMetrics !== this.targetMetricsOld)
|
||||||
if (this.rawQueryOld && newJson !== this.rawQueryOld) {
|
) {
|
||||||
this.refresh();
|
|
||||||
} else if (isPossiblyRawDataSwitch) {
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.rawQueryOld = newJson;
|
this.rawQueryOld = newJsonRawQuery;
|
||||||
|
this.targetMetricsOld = newJsonTargetMetrics;
|
||||||
this.$rootScope.appEvent(CoreEvents.elasticQueryUpdated);
|
this.$rootScope.appEvent(CoreEvents.elasticQueryUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user