Skip to content

Commit

Permalink
chore: filter undefined operators (#20157)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie authored May 23, 2022
1 parent 56e9695 commit d7e3ac3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,25 @@ export default function buildQueryContext(
} = typeof options === 'function'
? { buildQuery: options, queryFields: {} }
: options || {};
const queries = buildQuery(buildQueryObject(formData, queryFields), {
extras: {},
ownState,
hooks: {
setDataMask: () => {},
setCachedChanges: () => {},
...hooks,
},
});
queries.forEach(query => {
if (Array.isArray(query.post_processing)) {
// eslint-disable-next-line no-param-reassign
query.post_processing = query.post_processing.filter(Boolean);
}
});
return {
datasource: new DatasourceKey(formData.datasource).toObject(),
force: formData.force || false,
queries: buildQuery(buildQueryObject(formData, queryFields), {
extras: {},
ownState,
hooks: {
setDataMask: () => {},
setCachedChanges: () => {},
...hooks,
},
}),
queries,
form_data: formData,
result_format: formData.result_format || 'json',
result_type: formData.result_type || 'full',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function buildQuery(formData: QueryFormData) {
is_timeseries,
}),
flattenOperator(fd, queryObject),
].filter(Boolean),
],
} as QueryObject;
return [normalizeOrderBy(tmpQueryObject)];
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function buildQuery(formData: QueryFormData) {
flattenOperator(formData, baseQueryObject),
// todo: move prophet before flatten
prophetOperator(formData, baseQueryObject),
].filter(Boolean),
],
},
];
});
Expand Down

0 comments on commit d7e3ac3

Please sign in to comment.