Commit 2f9231ac authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Fix creating a custom stage

Updates the route for creating a
custom stage
parent 1db40d61
......@@ -42,15 +42,16 @@ export const receiveStageDataError = ({ commit }) => {
createFlash(__('There was an error fetching data for the selected stage'));
};
export const fetchStageData = ({ state, dispatch, getters }, slug) => {
const { cycleAnalyticsRequestParams = {} } = getters;
const {
selectedGroup: { fullPath },
} = state;
export const fetchStageData = ({ dispatch, getters }, slug) => {
const { cycleAnalyticsRequestParams = {}, currentValueStreamId, currentGroupPath } = getters;
dispatch('requestStageData');
return Api.cycleAnalyticsStageEvents(fullPath, slug, cycleAnalyticsRequestParams)
return Api.cycleAnalyticsStageEvents(
currentGroupPath,
currentValueStreamId,
slug,
cycleAnalyticsRequestParams,
)
.then(({ data }) => dispatch('receiveStageDataSuccess', data))
.catch(error => dispatch('receiveStageDataError', error));
};
......@@ -72,13 +73,23 @@ const fetchStageMedian = (currentGroupPath, stageId, params) =>
}));
export const fetchStageMedianValues = ({ dispatch, getters }) => {
const { currentGroupPath, cycleAnalyticsRequestParams, activeStages } = getters;
const {
currentGroupPath,
cycleAnalyticsRequestParams,
activeStages,
currentValueStreamId,
} = getters;
const stageIds = activeStages.map(s => s.slug);
dispatch('requestStageMedianValues');
return Promise.all(
stageIds.map(stageId =>
fetchStageMedian(currentGroupPath, stageId, cycleAnalyticsRequestParams),
fetchStageMedian(
currentGroupPath,
currentValueStreamId,
stageId,
cycleAnalyticsRequestParams,
),
),
)
.then(data => dispatch('receiveStageMedianValuesSuccess', data))
......
......@@ -23,13 +23,19 @@ export const receiveDurationDataError = ({ commit }) => {
export const fetchDurationData = ({ dispatch, rootGetters }) => {
dispatch('requestDurationData');
const { cycleAnalyticsRequestParams, activeStages, currentGroupPath } = rootGetters;
const {
cycleAnalyticsRequestParams,
activeStages,
currentGroupPath,
currentValueStreamId,
} = rootGetters;
return Promise.all(
activeStages.map(stage => {
const { slug } = stage;
return Api.cycleAnalyticsDurationChart(
currentGroupPath,
currentValueStreamId,
slug,
cycleAnalyticsRequestParams,
).then(({ data }) => ({
......@@ -53,7 +59,12 @@ export const receiveDurationMedianDataError = ({ commit }) => {
export const fetchDurationMedianData = ({ dispatch, rootState, rootGetters }) => {
const { startDate, endDate } = rootState;
const { cycleAnalyticsRequestParams, activeStages, currentGroupPath } = rootGetters;
const {
cycleAnalyticsRequestParams,
activeStages,
currentGroupPath,
currentValueStreamId,
} = rootGetters;
const offsetValue = getDayDifference(new Date(startDate), new Date(endDate));
const offsetCreatedAfter = getDateInPast(new Date(startDate), offsetValue);
......@@ -63,7 +74,7 @@ export const fetchDurationMedianData = ({ dispatch, rootState, rootGetters }) =>
activeStages.map(stage => {
const { slug } = stage;
return Api.cycleAnalyticsDurationChart(currentGroupPath, slug, {
return Api.cycleAnalyticsDurationChart(currentGroupPath, currentValueStreamId, slug, {
...cycleAnalyticsRequestParams,
created_after: dateFormat(offsetCreatedAfter, dateFormats.isoDate),
created_before: dateFormat(offsetCreatedBefore, dateFormats.isoDate),
......
......@@ -16,15 +16,17 @@ export default {
cycleAnalyticsTimeSummaryDataPath: '/groups/:id/-/analytics/value_stream_analytics/time_summary',
cycleAnalyticsGroupStagesAndEventsPath: '/groups/:id/-/analytics/value_stream_analytics/stages',
cycleAnalyticsValueStreamGroupStagesAndEventsPath:
'/groups/:id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages',
cycleAnalyticsValueStreamsPath: '/groups/:id/-/analytics/value_stream_analytics/value_streams',
'/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages',
cycleAnalyticsValueStreamsPath:
'/groups/:group_id/-/analytics/value_stream_analytics/value_streams',
cycleAnalyticsStageEventsPath:
'/groups/:id/-/analytics/value_stream_analytics/stages/:stage_id/records',
'/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/records',
cycleAnalyticsStageMedianPath:
'/groups/:id/-/analytics/value_stream_analytics/stages/:stage_id/median',
cycleAnalyticsStagePath: '/groups/:id/-/analytics/value_stream_analytics/stages/:stage_id',
'/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/median',
cycleAnalyticsStagePath:
'/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id',
cycleAnalyticsDurationChartPath:
'/groups/:id/-/analytics/value_stream_analytics/stages/:stage_id/duration_chart',
'/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/duration_chart',
cycleAnalyticsGroupLabelsPath: '/groups/:namespace_path/-/labels.json',
codeReviewAnalyticsPath: '/api/:version/analytics/code_review',
groupActivityIssuesPath: '/api/:version/analytics/group_activity/issues_count',
......@@ -146,23 +148,25 @@ export default {
cycleAnalyticsValueStreamGroupStagesAndEvents(groupId, valueStreamId, params = {}) {
const url = Api.buildUrl(this.cycleAnalyticsValueStreamGroupStagesAndEventsPath)
.replace(':id', groupId)
.replace(':group_id', groupId)
.replace(':value_stream_id', valueStreamId);
return axios.get(url, { params });
},
cycleAnalyticsStageEvents(groupId, stageId, params = {}) {
cycleAnalyticsStageEvents(groupId, valueStreamId, stageId, params = {}) {
const url = Api.buildUrl(this.cycleAnalyticsStageEventsPath)
.replace(':id', groupId)
.replace(':value_stream_id', valueStreamId)
.replace(':group_id', groupId)
.replace(':stage_id', stageId);
return axios.get(url, { params });
},
cycleAnalyticsStageMedian(groupId, stageId, params = {}) {
cycleAnalyticsStageMedian(groupId, valueStreamId, stageId, params = {}) {
const url = Api.buildUrl(this.cycleAnalyticsStageMedianPath)
.replace(':id', groupId)
.replace(':group_id', groupId)
.replace(':value_stream_id', valueStreamId)
.replace(':stage_id', stageId);
return axios.get(url, { params: { ...params } });
......@@ -170,43 +174,45 @@ export default {
cycleAnalyticsCreateStage(groupId, valueStreamId, data) {
const url = Api.buildUrl(this.cycleAnalyticsValueStreamGroupStagesAndEventsPath)
.replace(':id', groupId)
.replace(':group_id', groupId)
.replace(':value_stream_id', valueStreamId);
return axios.post(url, data);
},
cycleAnalyticsCreateValueStream(groupId, data) {
const url = Api.buildUrl(this.cycleAnalyticsValueStreamsPath).replace(':id', groupId);
const url = Api.buildUrl(this.cycleAnalyticsValueStreamsPath).replace(':group_id', groupId);
return axios.post(url, data);
},
cycleAnalyticsValueStreams(groupId, data) {
const url = Api.buildUrl(this.cycleAnalyticsValueStreamsPath).replace(':id', groupId);
const url = Api.buildUrl(this.cycleAnalyticsValueStreamsPath).replace(':group_id', groupId);
return axios.get(url, data);
},
cycleAnalyticsStageUrl(stageId, groupId) {
cycleAnalyticsStageUrl(groupId, valueStreamId, stageId) {
return Api.buildUrl(this.cycleAnalyticsStagePath)
.replace(':id', groupId)
.replace(':group_id', groupId)
.replace(':value_stream_id', valueStreamId)
.replace(':stage_id', stageId);
},
cycleAnalyticsUpdateStage(stageId, groupId, data) {
const url = this.cycleAnalyticsStageUrl(stageId, groupId);
cycleAnalyticsUpdateStage(groupId, valueStreamId, stageId, data) {
const url = this.cycleAnalyticsStageUrl(valueStreamId, stageId, groupId);
return axios.put(url, data);
},
cycleAnalyticsRemoveStage(stageId, groupId) {
const url = this.cycleAnalyticsStageUrl(stageId, groupId);
cycleAnalyticsRemoveStage(groupId, valueStreamId, stageId) {
const url = this.cycleAnalyticsStageUrl(groupId, valueStreamId, stageId);
return axios.delete(url);
},
cycleAnalyticsDurationChart(groupId, stageSlug, params = {}) {
cycleAnalyticsDurationChart(groupId, valueStreamId, stageSlug, params = {}) {
const url = Api.buildUrl(this.cycleAnalyticsDurationChartPath)
.replace(':id', groupId)
.replace(':group_id', groupId)
.replace(':value_stream_id', valueStreamId)
.replace(':stage_id', stageSlug);
return axios.get(url, {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment