Commit cf6e0fdd authored by Adam Hegyi's avatar Adam Hegyi

Fix passing project_ids to VSA

- Fix median calculation
- Fix duration chart median calculation
- Fix summary calculation
parent 92fc5dfe
......@@ -84,7 +84,7 @@ const fetchStageMedian = (currentGroupPath, stageId, params) =>
export const fetchStageMedianValues = ({ state, dispatch, getters }) => {
const {
currentGroupPath,
cycleAnalyticsRequestParams: { created_after, created_before },
cycleAnalyticsRequestParams: { created_after, created_before, project_ids },
} = getters;
const { stages } = state;
......@@ -92,6 +92,7 @@ export const fetchStageMedianValues = ({ state, dispatch, getters }) => {
group_id: currentGroupPath,
created_after,
created_before,
project_ids,
};
dispatch('requestStageMedianValues');
......@@ -183,7 +184,7 @@ export const receiveSummaryDataSuccess = ({ commit }, data) =>
export const fetchSummaryData = ({ state, dispatch, getters }) => {
const {
cycleAnalyticsRequestParams: { created_after, created_before },
cycleAnalyticsRequestParams: { created_after, created_before, project_ids },
} = getters;
dispatch('requestSummaryData');
......@@ -191,7 +192,12 @@ export const fetchSummaryData = ({ state, dispatch, getters }) => {
selectedGroup: { fullPath },
} = state;
return Api.cycleAnalyticsSummaryData({ group_id: fullPath, created_after, created_before })
return Api.cycleAnalyticsSummaryData({
group_id: fullPath,
created_after,
created_before,
project_ids,
})
.then(({ data }) => dispatch('receiveSummaryDataSuccess', data))
.catch(error =>
handleErrorOrRethrow({ error, action: () => dispatch('receiveSummaryDataError', error) }),
......@@ -518,7 +524,7 @@ export const receiveDurationMedianDataError = ({ commit }) => {
createFlash(__('There was an error while fetching value stream analytics duration median data.'));
};
export const fetchDurationMedianData = ({ state, dispatch }) => {
export const fetchDurationMedianData = ({ state, dispatch, getters }) => {
dispatch('requestDurationMedianData');
const {
......@@ -526,8 +532,10 @@ export const fetchDurationMedianData = ({ state, dispatch }) => {
selectedGroup: { fullPath },
startDate,
endDate,
selectedProjectIds,
} = state;
const {
cycleAnalyticsRequestParams: { project_ids },
} = getters;
const offsetValue = getDayDifference(new Date(startDate), new Date(endDate));
const offsetCreatedAfter = getDateInPast(new Date(startDate), offsetValue);
......@@ -541,7 +549,7 @@ export const fetchDurationMedianData = ({ state, dispatch }) => {
group_id: fullPath,
created_after: dateFormat(offsetCreatedAfter, dateFormats.isoDate),
created_before: dateFormat(offsetCreatedBefore, dateFormats.isoDate),
project_ids: selectedProjectIds,
project_ids,
}).then(({ data }) => ({
slug,
selected: true,
......
---
title: Fix passing project_ids to Value Stream Analytics
merge_request: 27895
author:
type: fixed
......@@ -36,7 +36,7 @@ describe Analytics::CycleAnalytics::SummaryController do
it 'contains `projects` parameter' do
params[:project_ids] = [-1]
expect(CycleAnalytics::GroupLevel).to receive(:new).with(group: group, options: hash_including(:projects)).and_call_original
expect(CycleAnalytics::GroupLevel).to receive(:new).with(group: group, options: hash_including(projects: ['-1'])).and_call_original
subject
......
......@@ -1188,6 +1188,7 @@ describe('Cycle analytics actions', () => {
.fetchDurationMedianData({
dispatch,
state: stateWithStages,
getters,
})
.then(() => {
expect(dispatch).toHaveBeenNthCalledWith(1, 'requestDurationMedianData');
......@@ -1208,6 +1209,7 @@ describe('Cycle analytics actions', () => {
.fetchDurationMedianData({
dispatch,
state: stateWithStages,
getters,
})
.then(() => {
expect(dispatch).toHaveBeenCalledWith(
......@@ -1235,6 +1237,7 @@ describe('Cycle analytics actions', () => {
.fetchDurationMedianData({
dispatch,
state: brokenState,
getters,
})
.then(() => {
expect(dispatch).toHaveBeenCalledWith('receiveDurationMedianDataError');
......
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