2019-07-07 11:18:12 +05:30
|
|
|
// Validate that the object coming in has valid query details and results
|
2021-03-08 18:12:59 +05:30
|
|
|
export const validateGraphData = (data) =>
|
2019-07-07 11:18:12 +05:30
|
|
|
data.queries &&
|
|
|
|
Array.isArray(data.queries) &&
|
2021-03-08 18:12:59 +05:30
|
|
|
data.queries.filter((query) => {
|
2019-07-07 11:18:12 +05:30
|
|
|
if (Array.isArray(query.result)) {
|
2021-03-08 18:12:59 +05:30
|
|
|
return query.result.filter((res) => Array.isArray(res.values)).length === query.result.length;
|
2019-07-07 11:18:12 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}).length === data.queries.length;
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
export const translate = (functions) =>
|
2019-07-07 11:18:12 +05:30
|
|
|
functions.reduce(
|
|
|
|
(acc, func) =>
|
|
|
|
Object.assign(acc, {
|
|
|
|
[func.environment_scope]: (acc[func.environment_scope] || []).concat([func]),
|
|
|
|
}),
|
|
|
|
{},
|
|
|
|
);
|