Skip to content

Commit

Permalink
simplify extract_index_pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Nov 24, 2020
1 parent 410cc4c commit 3145655
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/plugins/vis_type_vega/public/lib/extract_index_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@
*/

import { getData } from '../services';

import type { Data, VegaSpec } from '../data_model/types';
import type { IndexPattern } from '../../../data/public';

export const extractIndexPatternsFromSpec = async (spec: VegaSpec) => {
const { indexPatterns } = getData();
const data: Data[] = Array.isArray(spec.data) ? spec.data : [spec.data];

return (
await Promise.all(
(Array.isArray(spec.data) ? spec.data : [spec.data]).map((d: Data) => {
if (d?.url?.index) {
data.map((d) => {
if (d.url?.index) {
return indexPatterns.findByTitle(d.url.index);
}
})
Expand Down

0 comments on commit 3145655

Please sign in to comment.