Variables: improve performance of transformMetricFindResponse (#49360) (#51435)

* improve performance of transformMetricFindResponse

* use lodash uniqBy for postgres

* use lodash uniqBy for mysql

* use lodash uniqBy for mssql

* hopefully conform to import linting rules

* Added .betterer.results

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
Co-authored-by: Victor Marin <victor.marin@grafana.com>
(cherry picked from commit 683f31f2c6)

Co-authored-by: Nathaniel Saxe <NathanielSaxophone@gmail.com>
This commit is contained in:
Victor Marin
2022-06-27 05:02:30 -07:00
committed by GitHub
co-authored by Nathaniel Saxe
parent db5dee09d2
commit ddfdc9ee7a
3 changed files with 9 additions and 12 deletions
@@ -1,3 +1,5 @@
import { uniqBy } from 'lodash';
import { AnnotationEvent, DataFrame, MetricFindValue } from '@grafana/data';
import { BackendDataSourceResponse, toDataQueryResponse, FetchResponse } from '@grafana/runtime';
@@ -29,10 +31,7 @@ export default class ResponseParser {
);
}
return Array.from(new Set(values.map((v) => v.text))).map((text) => ({
text,
value: values.find((v) => v.text === text)?.value,
}));
return uniqBy(values, 'text');
}
async transformAnnotationResponse(options: any, data: BackendDataSourceResponse): Promise<AnnotationEvent[]> {
@@ -1,3 +1,5 @@
import { uniqBy } from 'lodash';
import { AnnotationEvent, DataFrame, MetricFindValue } from '@grafana/data';
import { BackendDataSourceResponse, FetchResponse, toDataQueryResponse } from '@grafana/runtime';
@@ -29,10 +31,7 @@ export default class ResponseParser {
);
}
return Array.from(new Set(values.map((v) => v.text))).map((text) => ({
text,
value: values.find((v) => v.text === text)?.value,
}));
return uniqBy(values, 'text');
}
async transformAnnotationResponse(options: any, data: BackendDataSourceResponse): Promise<AnnotationEvent[]> {
@@ -1,3 +1,5 @@
import { uniqBy } from 'lodash';
import { AnnotationEvent, DataFrame, MetricFindValue } from '@grafana/data';
import { BackendDataSourceResponse, FetchResponse, toDataQueryResponse } from '@grafana/runtime';
@@ -29,10 +31,7 @@ export default class ResponseParser {
);
}
return Array.from(new Set(values.map((v) => v.text))).map((text) => ({
text,
value: values.find((v) => v.text === text)?.value,
}));
return uniqBy(values, 'text');
}
async transformAnnotationResponse(options: any, data: BackendDataSourceResponse): Promise<AnnotationEvent[]> {