mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Performance: Standardize lodash imports to use destructured members (#33040)
* Performance: Standardize lodash imports to use destructured members
Changes lodash imports of the form `import x from 'lodash/x'` to
`import { x } from 'lodash'` to reduce bundle size.
* Remove unnecessary _ import from Graph component
* Enforce lodash import style
* Fix remaining lodash imports
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import _ from 'lodash';
|
||||
import { cloneDeep, map as _map, reduce, get, has, extend, omit, pick, isString } from 'lodash';
|
||||
|
||||
import {
|
||||
dateMath,
|
||||
@@ -120,12 +120,12 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
|
||||
classicQuery(options: any): Observable<DataQueryResponse> {
|
||||
let timeFilter = this.getTimeFilter(options);
|
||||
const scopedVars = options.scopedVars;
|
||||
const targets = _.cloneDeep(options.targets);
|
||||
const targets = cloneDeep(options.targets);
|
||||
const queryTargets: any[] = [];
|
||||
|
||||
let i, y;
|
||||
|
||||
let allQueries = _.map(targets, (target) => {
|
||||
let allQueries = _map(targets, (target) => {
|
||||
if (target.hide) {
|
||||
return '';
|
||||
}
|
||||
@@ -353,7 +353,7 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
|
||||
return '';
|
||||
}
|
||||
|
||||
return _.reduce(
|
||||
return reduce(
|
||||
params,
|
||||
(memo, value, key) => {
|
||||
if (value === null || value === undefined) {
|
||||
@@ -410,7 +410,7 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
|
||||
return this._seriesQuery(query)
|
||||
.toPromise()
|
||||
.then((res: any) => {
|
||||
const error = _.get(res, 'results[0].error');
|
||||
const error = get(res, 'results[0].error');
|
||||
if (error) {
|
||||
return { status: 'error', message: error };
|
||||
}
|
||||
@@ -440,13 +440,13 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
|
||||
|
||||
const { q } = data;
|
||||
|
||||
if (method === 'POST' && _.has(data, 'q')) {
|
||||
if (method === 'POST' && has(data, 'q')) {
|
||||
// verb is POST and 'q' param is defined
|
||||
_.extend(params, _.omit(data, ['q']));
|
||||
data = this.serializeParams(_.pick(data, ['q']));
|
||||
extend(params, omit(data, ['q']));
|
||||
data = this.serializeParams(pick(data, ['q']));
|
||||
} else if (method === 'GET' || method === 'POST') {
|
||||
// verb is GET, or POST without 'q' param
|
||||
_.extend(params, data);
|
||||
extend(params, data);
|
||||
data = null;
|
||||
}
|
||||
|
||||
@@ -540,7 +540,7 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
|
||||
}
|
||||
|
||||
getInfluxTime(date: any, roundUp: any, timezone: any) {
|
||||
if (_.isString(date)) {
|
||||
if (isString(date)) {
|
||||
if (date === 'now') {
|
||||
return 'now()';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user