2021-06-11 11:09:58 -04:00
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2021-08-06 14:09:57 -04:00
|
|
|
import { joinPaths } from '~/lib/utils/url_utility';
|
2021-06-11 11:09:58 -04:00
|
|
|
import { buildApiUrl } from './api_utils';
|
|
|
|
|
2021-08-16 08:09:17 -04:00
|
|
|
const PROJECT_VSA_METRICS_BASE = '/:request_path/-/analytics/value_stream_analytics';
|
2021-08-04 14:09:57 -04:00
|
|
|
const PROJECT_VSA_PATH_BASE = '/:request_path/-/analytics/value_stream_analytics/value_streams';
|
2021-06-11 11:09:58 -04:00
|
|
|
const PROJECT_VSA_STAGES_PATH = `${PROJECT_VSA_PATH_BASE}/:value_stream_id/stages`;
|
2021-08-04 14:09:57 -04:00
|
|
|
const PROJECT_VSA_STAGE_DATA_PATH = `${PROJECT_VSA_STAGES_PATH}/:stage_id`;
|
2021-06-11 11:09:58 -04:00
|
|
|
|
2021-08-16 08:09:17 -04:00
|
|
|
export const METRIC_TYPE_SUMMARY = 'summary';
|
|
|
|
export const METRIC_TYPE_TIME_SUMMARY = 'time_summary';
|
|
|
|
|
|
|
|
const buildProjectMetricsPath = (requestPath) =>
|
|
|
|
buildApiUrl(PROJECT_VSA_METRICS_BASE).replace(':request_path', requestPath);
|
|
|
|
|
2021-08-04 14:09:57 -04:00
|
|
|
const buildProjectValueStreamPath = (requestPath, valueStreamId = null) => {
|
2021-06-11 11:09:58 -04:00
|
|
|
if (valueStreamId) {
|
|
|
|
return buildApiUrl(PROJECT_VSA_STAGES_PATH)
|
2021-08-04 14:09:57 -04:00
|
|
|
.replace(':request_path', requestPath)
|
2021-06-11 11:09:58 -04:00
|
|
|
.replace(':value_stream_id', valueStreamId);
|
|
|
|
}
|
2021-08-04 14:09:57 -04:00
|
|
|
return buildApiUrl(PROJECT_VSA_PATH_BASE).replace(':request_path', requestPath);
|
2021-06-11 11:09:58 -04:00
|
|
|
};
|
|
|
|
|
2021-08-04 14:09:57 -04:00
|
|
|
const buildValueStreamStageDataPath = ({ requestPath, valueStreamId = null, stageId = null }) =>
|
|
|
|
buildApiUrl(PROJECT_VSA_STAGE_DATA_PATH)
|
|
|
|
.replace(':request_path', requestPath)
|
2021-07-15 14:09:37 -04:00
|
|
|
.replace(':value_stream_id', valueStreamId)
|
|
|
|
.replace(':stage_id', stageId);
|
|
|
|
|
2021-08-04 14:09:57 -04:00
|
|
|
export const getProjectValueStreams = (requestPath) => {
|
|
|
|
const url = buildProjectValueStreamPath(requestPath);
|
2021-06-11 11:09:58 -04:00
|
|
|
return axios.get(url);
|
|
|
|
};
|
|
|
|
|
2021-08-04 14:09:57 -04:00
|
|
|
export const getProjectValueStreamStages = (requestPath, valueStreamId) => {
|
|
|
|
const url = buildProjectValueStreamPath(requestPath, valueStreamId);
|
2021-06-11 11:09:58 -04:00
|
|
|
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 }) =>
|
2021-08-06 14:09:57 -04:00
|
|
|
axios.get(joinPaths(requestPath, 'events', stageId), { params });
|
2021-06-11 11:09:58 -04:00
|
|
|
|
2021-07-15 14:09:37 -04:00
|
|
|
/**
|
2021-08-16 08:09:17 -04:00
|
|
|
* Dedicated project VSA paths
|
2021-07-15 14:09:37 -04:00
|
|
|
*/
|
|
|
|
|
2021-08-04 14:09:57 -04:00
|
|
|
export const getValueStreamStageMedian = ({ requestPath, valueStreamId, stageId }, params = {}) => {
|
|
|
|
const stageBase = buildValueStreamStageDataPath({ requestPath, valueStreamId, stageId });
|
2021-08-06 14:09:57 -04:00
|
|
|
return axios.get(joinPaths(stageBase, 'median'), { params });
|
2021-07-15 14:09:37 -04:00
|
|
|
};
|
2021-08-04 14:09:57 -04:00
|
|
|
|
|
|
|
export const getValueStreamStageRecords = (
|
|
|
|
{ requestPath, valueStreamId, stageId },
|
|
|
|
params = {},
|
|
|
|
) => {
|
|
|
|
const stageBase = buildValueStreamStageDataPath({ requestPath, valueStreamId, stageId });
|
2021-08-06 14:09:57 -04:00
|
|
|
return axios.get(joinPaths(stageBase, 'records'), { params });
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getValueStreamStageCounts = ({ requestPath, valueStreamId, stageId }, params = {}) => {
|
|
|
|
const stageBase = buildValueStreamStageDataPath({ requestPath, valueStreamId, stageId });
|
|
|
|
return axios.get(joinPaths(stageBase, 'count'), { params });
|
2021-08-04 14:09:57 -04:00
|
|
|
};
|
2021-08-16 08:09:17 -04:00
|
|
|
|
|
|
|
export const getValueStreamMetrics = ({
|
|
|
|
endpoint = METRIC_TYPE_SUMMARY,
|
|
|
|
requestPath,
|
|
|
|
params = {},
|
|
|
|
}) => {
|
|
|
|
const metricBase = buildProjectMetricsPath(requestPath);
|
|
|
|
return axios.get(joinPaths(metricBase, endpoint), { params });
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getValueStreamSummaryMetrics = (requestPath, params = {}) => {
|
|
|
|
const metricBase = buildProjectMetricsPath(requestPath);
|
|
|
|
return axios.get(joinPaths(metricBase, 'summary'), { params });
|
|
|
|
};
|