summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/api/analytics_api.js
blob: 58494c5a2b8c6167099494c1887cc2dd5cbeede8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import axios from '~/lib/utils/axios_utils';
import { buildApiUrl } from './api_utils';

const PROJECT_VSA_PATH_BASE = '/:project_path/-/analytics/value_stream_analytics/value_streams';
const PROJECT_VSA_STAGES_PATH = `${PROJECT_VSA_PATH_BASE}/:value_stream_id/stages`;

const buildProjectValueStreamPath = (projectPath, valueStreamId = null) => {
  if (valueStreamId) {
    return buildApiUrl(PROJECT_VSA_STAGES_PATH)
      .replace(':project_path', projectPath)
      .replace(':value_stream_id', valueStreamId);
  }
  return buildApiUrl(PROJECT_VSA_PATH_BASE).replace(':project_path', projectPath);
};

export const getProjectValueStreams = (projectPath) => {
  const url = buildProjectValueStreamPath(projectPath);
  return axios.get(url);
};

export const getProjectValueStreamStages = (projectPath, valueStreamId) => {
  const url = buildProjectValueStreamPath(projectPath, valueStreamId);
  return axios.get(url);
};

// NOTE: legacy VSA request use a different path
// the `requestPath` provides a full url for the request
export const getProjectValueStreamStageData = ({ requestPath, stageId, params }) =>
  axios.get(`${requestPath}/events/${stageId}`, { params });

export const getProjectValueStreamMetrics = (requestPath, params) =>
  axios.get(requestPath, { params });