Skip to content

Commit

Permalink
fix: wrong dates on last x date on omnichannel reports (#34113)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchoeler authored Dec 24, 2024
1 parent d1d096e commit b31e7f9
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 17 deletions.
10 changes: 10 additions & 0 deletions .changeset/quick-rivers-ring.md
Original file line number Diff line number Diff line change
@@ -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
17 changes: 11 additions & 6 deletions apps/meteor/client/components/dashboards/periods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -32,7 +37,7 @@ const periods = [
{
key: 'this week',
label: label('This_week'),
range: lastNDays(7),
range: lastNDays(moment().day()),
},
{
key: 'last 7 days',
Expand All @@ -47,7 +52,7 @@ const periods = [
{
key: 'this month',
label: label('This_month'),
range: lastNDays(30),
range: lastNDays(moment().date()),
},
{
key: 'last 30 days',
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
8 changes: 4 additions & 4 deletions apps/meteor/tests/e2e/omnichannel/omnichannel-reports.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});

Expand Down Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/i18n/src/locales/hi-IN.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2797,7 +2797,6 @@
"Last_30_days": "पिछले 30 दिनों में",
"Last_90_days": "पिछले 90 दिन",
"Last_6_months": "पिछले 6 महीने",
"Last_year": "पिछले साल",
"Last_active": "अंतिम सक्रिय",
"Last_Call": "आखिरी कॉल",
"Last_Chat": "आखिरी चैट",
Expand Down
1 change: 0 additions & 1 deletion packages/i18n/src/locales/nn.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/i18n/src/locales/no.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/src/locales/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/i18n/src/locales/se.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b31e7f9

Please sign in to comment.