diff --git a/.changeset/quick-rivers-ring.md b/.changeset/quick-rivers-ring.md new file mode 100644 index 000000000000..d628f1b29eba --- /dev/null +++ b/.changeset/quick-rivers-ring.md @@ -0,0 +1,10 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixes dates being incorrect when fetching omnichannel reports with the following time periods: + +last week +last month +last 6 months +last year diff --git a/apps/meteor/client/components/dashboards/periods.ts b/apps/meteor/client/components/dashboards/periods.ts index 6da6ab9e9bd0..824064b99d6c 100644 --- a/apps/meteor/client/components/dashboards/periods.ts +++ b/apps/meteor/client/components/dashboards/periods.ts @@ -23,6 +23,11 @@ const lastNDays = return { start, end }; }; +const getLast6Months = () => { + const last6Months = moment().subtract(6, 'months'); + return moment().diff(last6Months, 'days'); +}; + const periods = [ { key: 'today', @@ -32,7 +37,7 @@ const periods = [ { key: 'this week', label: label('This_week'), - range: lastNDays(7), + range: lastNDays(moment().day()), }, { key: 'last 7 days', @@ -47,7 +52,7 @@ const periods = [ { key: 'this month', label: label('This_month'), - range: lastNDays(30), + range: lastNDays(moment().date()), }, { key: 'last 30 days', @@ -62,12 +67,12 @@ const periods = [ { key: 'last 6 months', label: label('Last_6_months'), - range: lastNDays(180), + range: lastNDays(getLast6Months()), }, { - key: 'last year', - label: label('Last_year'), - range: lastNDays(365), + key: 'this year', + label: label('This_year'), + range: lastNDays(moment().dayOfYear()), }, ] as const; diff --git a/apps/meteor/client/omnichannel/reports/components/constants.ts b/apps/meteor/client/omnichannel/reports/components/constants.ts index c69fae35f374..a00dbe73403f 100644 --- a/apps/meteor/client/omnichannel/reports/components/constants.ts +++ b/apps/meteor/client/omnichannel/reports/components/constants.ts @@ -41,4 +41,4 @@ export const COLORS = { warning2: Palette.statusColor['status-font-on-warning-2'].toString(), }; -export const PERIOD_OPTIONS: Period['key'][] = ['today', 'this week', 'last 15 days', 'this month', 'last 6 months', 'last year']; +export const PERIOD_OPTIONS: Period['key'][] = ['today', 'this week', 'last 15 days', 'this month', 'last 6 months', 'this year']; diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-reports.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-reports.spec.ts index f336bf7eab62..2fcc6cff2ad0 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-reports.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-reports.spec.ts @@ -90,12 +90,12 @@ test.describe.serial('Omnichannel Reports', () => { await route.fulfill({ response, json: mock }); }); - await poReports.statusSection.selectPeriod('last year'); + await poReports.statusSection.selectPeriod('this year'); await expect(poReports.statusSection.legendItem(`Closed 25 (25%)`)).toBeVisible(); await expect(poReports.statusSection.legendItem(`Open 25 (25%)`)).toBeVisible(); await expect(poReports.statusSection.legendItem(`Queued 25 (25%)`)).toBeVisible(); await expect(poReports.statusSection.legendItem(`On hold 25 (25%)`)).toBeVisible(); - await expect(poReports.statusSection.txtSummary).toHaveText('100 conversations, last year'); + await expect(poReports.statusSection.txtSummary).toHaveText('100 conversations, this year'); }); }); @@ -145,10 +145,10 @@ test.describe.serial('Omnichannel Reports', () => { await route.fulfill({ response, json: mock }); }); - await poReports.channelsSection.selectPeriod('last year'); + await poReports.channelsSection.selectPeriod('this year'); await expect(poReports.channelsSection.legendItem(`Channel 1 50 (50%)`)).toBeVisible(); await expect(poReports.channelsSection.legendItem(`Channel 2 50 (50%)`)).toBeVisible(); - await expect(poReports.channelsSection.txtSummary).toHaveText('100 conversations, last year'); + await expect(poReports.channelsSection.txtSummary).toHaveText('100 conversations, this year'); }); await test.step('More than 5 channels', async () => { diff --git a/packages/i18n/src/locales/en.i18n.json b/packages/i18n/src/locales/en.i18n.json index 134bfbbee6fe..93ea90a09a3c 100644 --- a/packages/i18n/src/locales/en.i18n.json +++ b/packages/i18n/src/locales/en.i18n.json @@ -3052,7 +3052,6 @@ "Last_30_days": "Last 30 Days", "Last_90_days": "Last 90 Days", "Last_6_months": "Last 6 months", - "Last_year": "Last year", "Last_active": "Last active", "Last_Call": "Last Call", "Last_Chat": "Last Chat", @@ -4510,6 +4509,7 @@ "Readability": "Readability", "This_room_is_read_only": "This room is read only", "This_page_will_be_deprecated_soon": "This page will be deprecated soon", + "This_year": "This Year", "Only_people_with_permission_can_send_messages_here": "Only people with permission can send messages here", "Read_only_changed_successfully": "Read only changed successfully", "Read_only_channel": "Read Only Channel", diff --git a/packages/i18n/src/locales/hi-IN.i18n.json b/packages/i18n/src/locales/hi-IN.i18n.json index 51c14ebf42c3..2a88e325716d 100644 --- a/packages/i18n/src/locales/hi-IN.i18n.json +++ b/packages/i18n/src/locales/hi-IN.i18n.json @@ -2797,7 +2797,6 @@ "Last_30_days": "पिछले 30 दिनों में", "Last_90_days": "पिछले 90 दिन", "Last_6_months": "पिछले 6 महीने", - "Last_year": "पिछले साल", "Last_active": "अंतिम सक्रिय", "Last_Call": "आखिरी कॉल", "Last_Chat": "आखिरी चैट", diff --git a/packages/i18n/src/locales/nn.i18n.json b/packages/i18n/src/locales/nn.i18n.json index 61c45461f9dc..b1b7759f3d1c 100644 --- a/packages/i18n/src/locales/nn.i18n.json +++ b/packages/i18n/src/locales/nn.i18n.json @@ -2474,7 +2474,6 @@ "Last_30_days": "Siste 30 dager", "Last_90_days": "Siste 90 dager", "Last_6_months": "Siste 6 måneder", - "Last_year": "I fjor", "Last_active": "Sist aktiv", "Last_Call": "Siste samtale", "Last_login": "Siste innlogging", diff --git a/packages/i18n/src/locales/no.i18n.json b/packages/i18n/src/locales/no.i18n.json index 3eb0a8d29d5e..605893a6bfb9 100644 --- a/packages/i18n/src/locales/no.i18n.json +++ b/packages/i18n/src/locales/no.i18n.json @@ -2474,7 +2474,6 @@ "Last_30_days": "Siste 30 dager", "Last_90_days": "Siste 90 dager", "Last_6_months": "Siste 6 måneder", - "Last_year": "I fjor", "Last_active": "Sist aktiv", "Last_Call": "Siste samtale", "Last_login": "Siste innlogging", diff --git a/packages/i18n/src/locales/pt-BR.i18n.json b/packages/i18n/src/locales/pt-BR.i18n.json index f77743f7f3f8..5ec5f61650df 100644 --- a/packages/i18n/src/locales/pt-BR.i18n.json +++ b/packages/i18n/src/locales/pt-BR.i18n.json @@ -2465,7 +2465,6 @@ "Last_30_days": "Últimos 30 dias", "Last_90_days": "Últimos 90 dias", "Last_6_months": "Últimos 6 meses", - "Last_year": "Último ano", "Last_active": "Ativo pela última vez", "Last_Call": "Última chamada", "Last_Chat": "Última conversa", @@ -3533,6 +3532,7 @@ "Read_by": "Lido por", "Read_only": "Somente leitura", "This_room_is_read_only": "Esta sala é somente leitura", + "This_year": "Este ano", "Read_only_changed_successfully": "Somente leitura foi alterado com sucesso", "Read_only_channel": "Canal somente leitura", "Read_only_group": "Grupo somente de leitura", diff --git a/packages/i18n/src/locales/se.i18n.json b/packages/i18n/src/locales/se.i18n.json index 1d0359279977..f86cfc3b9472 100644 --- a/packages/i18n/src/locales/se.i18n.json +++ b/packages/i18n/src/locales/se.i18n.json @@ -2963,7 +2963,6 @@ "Last_30_days": "Last 30 Days", "Last_90_days": "Last 90 Days", "Last_6_months": "Last 6 months", - "Last_year": "Last year", "Last_active": "Last active", "Last_Call": "Last Call", "Last_Chat": "Last Chat",