All files / ee/app/assets/javascripts/api analytics_api.js

81.82% Statements 9/11
0% Branches 0/5
50% Functions 2/4
81.82% Lines 9/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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          28x 28x   28x     28x 274x         28x       274x 274x     28x          
import { METRIC_TYPE_SUMMARY } from '~/api/analytics_api';
import { buildApiUrl } from '~/api/api_utils';
import axios from '~/lib/utils/axios_utils';
import { joinPaths } from '~/lib/utils/url_utility';
 
const GROUP_VSA_BASE = '/groups/:id/-/analytics/value_stream_analytics';
const GROUP_VSA_STAGE_BASE = `${GROUP_VSA_BASE}/value_streams/:value_stream_id/stages/:stage_id`;
 
const buildGroupValueStreamPath = ({ groupId }) =>
  buildApiUrl(GROUP_VSA_BASE).replace(':id', groupId);
 
const buildGroupValueStreamStagePath = ({ groupId, valueStreamId = null, stageId = null }) =>
  buildApiUrl(GROUP_VSA_STAGE_BASE)
    .replace(':id', groupId)
    .replace(':value_stream_id', valueStreamId)
    .replace(':stage_id', stageId);
 
export const getGroupValueStreamStageMedian = (
  { groupId, valueStreamId, stageId },
  params = {},
) => {
  const stageBase = buildGroupValueStreamStagePath({ groupId, valueStreamId, stageId });
  return axios.get(`${stageBase}/median`, { params });
};
 
export const getGroupValueStreamMetrics = ({
  endpoint = METRIC_TYPE_SUMMARY,
  requestPath: groupId,
  params = {},
}) => axios.get(joinPaths(buildGroupValueStreamPath({ groupId }), endpoint), { params });