summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/serverless/utils.js
blob: 1bf03ea8d4255685abdd83cb8854eec90c29b62b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Validate that the object coming in has valid query details and results
export const validateGraphData = data =>
  data.queries &&
  Array.isArray(data.queries) &&
  data.queries.filter(query => {
    if (Array.isArray(query.result)) {
      return query.result.filter(res => Array.isArray(res.values)).length === query.result.length;
    }

    return false;
  }).length === data.queries.length;

export const translate = functions =>
  functions.reduce(
    (acc, func) =>
      Object.assign(acc, {
        [func.environment_scope]: (acc[func.environment_scope] || []).concat([func]),
      }),
    {},
  );