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