Commit 67abfa8a authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by Brandon Labuschagne

[VSA] Fix duplicate summary data request

parent deb24d90
<script>
import { GlEmptyState } from '@gitlab/ui';
import { mapActions, mapState, mapGetters } from 'vuex';
import { toYmd } from '~/analytics/shared/utils';
import PathNavigation from '~/cycle_analytics/components/path_navigation.vue';
import StageTable from '~/cycle_analytics/components/stage_table.vue';
import ValueStreamFilters from '~/cycle_analytics/components/value_stream_filters.vue';
......@@ -84,7 +83,7 @@ export default {
return this.createdAfter && this.createdBefore;
},
query() {
const selectedProjectIds = this.selectedProjectIds?.length ? this.selectedProjectIds : null;
const { project_ids, created_after, created_before } = this.cycleAnalyticsRequestParams;
const paginationUrlParams = !this.isOverviewStageSelected
? {
sort: this.pagination?.sort || null,
......@@ -99,9 +98,9 @@ export default {
return {
value_stream_id: this.selectedValueStream?.id || null,
project_ids: selectedProjectIds,
created_after: toYmd(this.createdAfter),
created_before: toYmd(this.createdBefore),
project_ids,
created_after,
created_before,
stage_id: (!this.isOverviewStageSelected && this.selectedStage?.id) || null, // the `overview` stage is always the default, so dont persist the id if its selected
...paginationUrlParams,
};
......
......@@ -42,7 +42,7 @@ export const cycleAnalyticsRequestParams = (state, getters) => {
});
return {
project_ids: getters.selectedProjectIds,
project_ids: getters.selectedProjectIds?.length ? getters.selectedProjectIds : null,
created_after: createdAfter ? dateFormat(createdAfter, dateFormats.isoDate) : null,
created_before: createdBefore ? dateFormat(createdBefore, dateFormats.isoDate) : null,
...filterBarQuery,
......
......@@ -118,7 +118,7 @@ export const buildCycleAnalyticsInitialData = ({
createdAfter: createdAfter ? new Date(createdAfter) : null,
selectedProjects: projects
? buildProjectsFromJSON(projects).map(convertObjectPropsToCamelCase)
: [],
: null,
labelsPath,
milestonesPath,
defaultStageConfig: defaultStages
......
......@@ -484,7 +484,7 @@ describe('EE Value Stream Analytics component', () => {
wrapper = null;
});
describe('with minimal parameters set set', () => {
describe('with minimal parameters set', () => {
beforeEach(async () => {
wrapper = await createComponent();
......
......@@ -86,7 +86,7 @@ describe('buildCycleAnalyticsInitialData', () => {
${'group'} | ${null}
${'createdBefore'} | ${null}
${'createdAfter'} | ${null}
${'selectedProjects'} | ${[]}
${'selectedProjects'} | ${null}
${'labelsPath'} | ${''}
${'milestonesPath'} | ${''}
${'stage'} | ${null}
......@@ -152,13 +152,13 @@ describe('buildCycleAnalyticsInitialData', () => {
});
it.each`
field | value
${'selectedProjects'} | ${null}
${'selectedProjects'} | ${[]}
${'selectedProjects'} | ${''}
`('will be an empty array if given a value of `$value`', ({ value, field }) => {
field | value | result
${'selectedProjects'} | ${null} | ${null}
${'selectedProjects'} | ${[]} | ${[]}
${'selectedProjects'} | ${''} | ${null}
`('will be an empty array if given a value of `$value`', ({ value, field, result }) => {
expect(buildCycleAnalyticsInitialData({ projects: value })).toMatchObject({
[field]: [],
[field]: result,
});
});
});
......
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