Commit dfb0f7e6 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'ek-vsa-fix-incorrect-date-values' into 'master'

Fix incorrect display date in group VSA task by type

See merge request gitlab-org/gitlab!71350
parents 0d597507 56ef35ed
...@@ -45,6 +45,7 @@ export default () => { ...@@ -45,6 +45,7 @@ export default () => {
new Vue({ new Vue({
el, el,
name: 'CycleAnalytics', name: 'CycleAnalytics',
apolloProvider: {},
store, store,
render: (createElement) => render: (createElement) =>
createElement(CycleAnalytics, { createElement(CycleAnalytics, {
......
...@@ -28,8 +28,8 @@ export default { ...@@ -28,8 +28,8 @@ export default {
}, },
summaryDescription() { summaryDescription() {
const { const {
startDate, createdAfter,
endDate, createdBefore,
selectedProjectIds, selectedProjectIds,
currentGroup: { name: groupName }, currentGroup: { name: groupName },
} = this.selectedTasksByTypeFilters; } = this.selectedTasksByTypeFilters;
...@@ -38,14 +38,14 @@ export default { ...@@ -38,14 +38,14 @@ export default {
const str = const str =
selectedProjectCount > 0 selectedProjectCount > 0
? s__( ? s__(
"CycleAnalytics|Showing data for group '%{groupName}' and %{selectedProjectCount} projects from %{startDate} to %{endDate}", "CycleAnalytics|Showing data for group '%{groupName}' and %{selectedProjectCount} projects from %{createdAfter} to %{createdBefore}",
) )
: s__( : s__(
"CycleAnalytics|Showing data for group '%{groupName}' from %{startDate} to %{endDate}", "CycleAnalytics|Showing data for group '%{groupName}' from %{createdAfter} to %{createdBefore}",
); );
return sprintf(str, { return sprintf(str, {
startDate: formattedDate(startDate), createdAfter: formattedDate(createdAfter),
endDate: formattedDate(endDate), createdBefore: formattedDate(createdBefore),
groupName, groupName,
selectedProjectCount, selectedProjectCount,
}); });
......
...@@ -21,10 +21,6 @@ export const selectedTasksByTypeFilters = (state = {}, _, rootState = {}) => { ...@@ -21,10 +21,6 @@ export const selectedTasksByTypeFilters = (state = {}, _, rootState = {}) => {
export const tasksByTypeChartData = ({ data = [] } = {}, _, rootState = {}) => { export const tasksByTypeChartData = ({ data = [] } = {}, _, rootState = {}) => {
const { createdAfter = null, createdBefore = null } = rootState; const { createdAfter = null, createdBefore = null } = rootState;
return data.length return data.length
? getTasksByTypeData({ ? getTasksByTypeData({ data, createdAfter, createdBefore })
data,
startDate: createdAfter,
endDate: createdBefore,
})
: { groupBy: [], data: [] }; : { groupBy: [], data: [] };
}; };
...@@ -214,20 +214,20 @@ export const flattenTaskByTypeSeries = (series = {}) => ...@@ -214,20 +214,20 @@ export const flattenTaskByTypeSeries = (series = {}) =>
* *
* @param {Object} obj * @param {Object} obj
* @param {RawTasksByTypeData[]} obj.data - array of raw data, each element contains a label and series * @param {RawTasksByTypeData[]} obj.data - array of raw data, each element contains a label and series
* @param {Date} obj.startDate - start date in ISO date format * @param {Date} obj.createdAfter - start date in ISO date format
* @param {Date} obj.endDate - end date in ISO date format * @param {Date} obj.createdBefore - end date in ISO date format
* *
* @returns {TransformedTasksByTypeData} The transformed data ready for use in charts * @returns {TransformedTasksByTypeData} The transformed data ready for use in charts
*/ */
export const getTasksByTypeData = ({ data = [], startDate = null, endDate = null }) => { export const getTasksByTypeData = ({ data = [], createdAfter = null, createdBefore = null }) => {
if (!startDate || !endDate || !data.length) { if (!createdAfter || !createdBefore || !data.length) {
return { return {
groupBy: [], groupBy: [],
data: [], data: [],
}; };
} }
const groupBy = getDatesInRange(startDate, endDate, toYmd).sort(orderByDate); const groupBy = getDatesInRange(createdAfter, createdBefore, toYmd).sort(orderByDate);
const zeroValuesForEachDataPoint = groupBy.reduce( const zeroValuesForEachDataPoint = groupBy.reduce(
(acc, date) => ({ (acc, date) => ({
...acc, ...acc,
......
...@@ -212,6 +212,7 @@ RSpec.describe 'Group value stream analytics filters and data', :js do ...@@ -212,6 +212,7 @@ RSpec.describe 'Group value stream analytics filters and data', :js do
expect(element.find('.js-daterange-picker-from input').value).to eq '2019-11-01' expect(element.find('.js-daterange-picker-from input').value).to eq '2019-11-01'
expect(element.find('.js-daterange-picker-to input').value).to eq '2019-12-31' expect(element.find('.js-daterange-picker-to input').value).to eq '2019-12-31'
expect(page.find('.js-tasks-by-type-chart')).to have_text(_("Showing data for group '%{group_name}' from Nov 1, 2019 to Dec 31, 2019") % { group_name: group.name })
end end
end end
end end
......
...@@ -222,8 +222,8 @@ export const taskByTypeFilters = { ...@@ -222,8 +222,8 @@ export const taskByTypeFilters = {
fullPath: 'gitlab-org', fullPath: 'gitlab-org',
}, },
selectedProjectIds: [], selectedProjectIds: [],
startDate: new Date('2019-12-11'), createdAfter: new Date('2019-12-11'),
endDate: new Date('2020-01-10'), createdBefore: new Date('2020-01-10'),
subject: TASKS_BY_TYPE_SUBJECT_ISSUE, subject: TASKS_BY_TYPE_SUBJECT_ISSUE,
selectedLabelIds: [1, 2, 3], selectedLabelIds: [1, 2, 3],
}; };
......
...@@ -247,22 +247,20 @@ describe('Value Stream Analytics utils', () => { ...@@ -247,22 +247,20 @@ describe('Value Stream Analytics utils', () => {
}); });
it('will return blank arrays if given no data', () => { it('will return blank arrays if given no data', () => {
[{ data: [], startDate: createdAfter, endDate: createdBefore }, [], {}].forEach( [{ data: [], createdAfter, createdBefore }, [], {}].forEach((chartData) => {
(chartData) => {
transformed = getTasksByTypeData(chartData); transformed = getTasksByTypeData(chartData);
['data', 'groupBy'].forEach((key) => { ['data', 'groupBy'].forEach((key) => {
expect(transformed[key]).toEqual([]); expect(transformed[key]).toEqual([]);
}); });
}, });
);
}); });
describe('with data', () => { describe('with data', () => {
beforeEach(() => { beforeEach(() => {
transformed = getTasksByTypeData({ transformed = getTasksByTypeData({
data: rawTasksByTypeData, data: rawTasksByTypeData,
startDate: createdAfter, createdAfter,
endDate: createdBefore, createdBefore,
}); });
}); });
......
...@@ -10198,10 +10198,10 @@ msgid_plural "CycleAnalytics|Showing %{subjectFilterText} and %{selectedLabelsCo ...@@ -10198,10 +10198,10 @@ msgid_plural "CycleAnalytics|Showing %{subjectFilterText} and %{selectedLabelsCo
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
msgid "CycleAnalytics|Showing data for group '%{groupName}' and %{selectedProjectCount} projects from %{startDate} to %{endDate}" msgid "CycleAnalytics|Showing data for group '%{groupName}' and %{selectedProjectCount} projects from %{createdAfter} to %{createdBefore}"
msgstr "" msgstr ""
msgid "CycleAnalytics|Showing data for group '%{groupName}' from %{startDate} to %{endDate}" msgid "CycleAnalytics|Showing data for group '%{groupName}' from %{createdAfter} to %{createdBefore}"
msgstr "" msgstr ""
msgid "CycleAnalytics|Stages" msgid "CycleAnalytics|Stages"
...@@ -31289,6 +31289,9 @@ msgstr "" ...@@ -31289,6 +31289,9 @@ msgstr ""
msgid "Showing all issues" msgid "Showing all issues"
msgstr "" msgstr ""
msgid "Showing data for group '%{group_name}' from Nov 1, 2019 to Dec 31, 2019"
msgstr ""
msgid "Showing data for workflow items created in this date range. Date range cannot exceed %{maxDateRange} days." msgid "Showing data for workflow items created in this date range. Date range cannot exceed %{maxDateRange} days."
msgstr "" msgstr ""
......
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