Skip to content

Commit

Permalink
chore: cache legacy omnichannel analytics (#30493)
Browse files Browse the repository at this point in the history
  • Loading branch information
murtaza98 authored Oct 26, 2023
1 parent e3db085 commit df2b989
Show file tree
Hide file tree
Showing 5 changed files with 798 additions and 779 deletions.
36 changes: 18 additions & 18 deletions apps/meteor/app/livechat/imports/server/rest/dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { isGETDashboardTotalizerParams, isGETDashboardsAgentStatusParams } from

import { API } from '../../../../api/server';
import {
findAllChatsStatusAsync,
getProductivityMetricsAsync,
getConversationsMetricsAsync,
findAllChatMetricsByAgentAsync,
findAllAgentsStatusAsync,
findAllChatMetricsByDepartmentAsync,
findAllResponseTimeMetricsAsync,
getAgentsProductivityMetricsAsync,
getChatsMetricsAsync,
getProductivityMetricsAsyncCached,
getConversationsMetricsAsyncCached,
getAgentsProductivityMetricsAsyncCached,
getChatsMetricsAsyncCached,
findAllChatsStatusAsyncCached,
findAllChatMetricsByAgentAsyncCached,
findAllAgentsStatusAsyncCached,
findAllChatMetricsByDepartmentAsyncCached,
findAllResponseTimeMetricsAsyncCached,
} from '../../../server/lib/analytics/dashboards';

API.v1.addRoute(
Expand Down Expand Up @@ -41,7 +41,7 @@ API.v1.addRoute(
return API.v1.failure('User not found');
}

const totalizers = await getConversationsMetricsAsync({ start: startDate, end: endDate, departmentId, user });
const totalizers = await getConversationsMetricsAsyncCached({ start: startDate, end: endDate, departmentId, user });
return API.v1.success(totalizers);
},
},
Expand Down Expand Up @@ -70,7 +70,7 @@ API.v1.addRoute(
return API.v1.failure('User not found');
}

const totalizers = await getAgentsProductivityMetricsAsync({ start: startDate, end: endDate, departmentId, user });
const totalizers = await getAgentsProductivityMetricsAsyncCached({ start: startDate, end: endDate, departmentId, user });
return API.v1.success(totalizers);
},
},
Expand All @@ -94,7 +94,7 @@ API.v1.addRoute(
}
const endDate = new Date(end);

const totalizers = await getChatsMetricsAsync({ start: startDate, end: endDate, departmentId });
const totalizers = await getChatsMetricsAsyncCached({ start: startDate, end: endDate, departmentId });
return API.v1.success(totalizers);
},
},
Expand Down Expand Up @@ -123,7 +123,7 @@ API.v1.addRoute(
return API.v1.failure('User not found');
}

const totalizers = await getProductivityMetricsAsync({ start: startDate, end: endDate, departmentId, user });
const totalizers = await getProductivityMetricsAsyncCached({ start: startDate, end: endDate, departmentId, user });

return API.v1.success(totalizers);
},
Expand All @@ -148,7 +148,7 @@ API.v1.addRoute(
}
const endDate = new Date(end);

const result = await findAllChatsStatusAsync({ start: startDate, end: endDate, departmentId });
const result = await findAllChatsStatusAsyncCached({ start: startDate, end: endDate, departmentId });

return API.v1.success(result);
},
Expand All @@ -172,7 +172,7 @@ API.v1.addRoute(
return API.v1.failure('The "end" query parameter must be a valid date.');
}
const endDate = new Date(end);
const result = (await findAllChatMetricsByAgentAsync({ start: startDate, end: endDate, departmentId })) as {
const result = (await findAllChatMetricsByAgentAsyncCached({ start: startDate, end: endDate, departmentId })) as {
[k: string]: { open: number; closed: number; onhold: number };
};

Expand All @@ -188,7 +188,7 @@ API.v1.addRoute(
async get() {
const { departmentId } = this.queryParams;

const result = await findAllAgentsStatusAsync({ departmentId });
const result = await findAllAgentsStatusAsyncCached({ departmentId });

return API.v1.success(result);
},
Expand All @@ -213,7 +213,7 @@ API.v1.addRoute(
}
const endDate = new Date(end);

const result = (await findAllChatMetricsByDepartmentAsync({ start: startDate, end: endDate, departmentId })) as {
const result = (await findAllChatMetricsByDepartmentAsyncCached({ start: startDate, end: endDate, departmentId })) as {
[k: string]: { open: number; closed: number };
};

Expand All @@ -240,7 +240,7 @@ API.v1.addRoute(
}
const endDate = new Date(end);

const result = await findAllResponseTimeMetricsAsync({ start: startDate, end: endDate, departmentId });
const result = await findAllResponseTimeMetricsAsyncCached({ start: startDate, end: endDate, departmentId });

return API.v1.success(result);
},
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/livechat/server/api/v1/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isLivechatAnalyticsAgentOverviewProps, isLivechatAnalyticsOverviewProps

import { API } from '../../../../api/server';
import { settings } from '../../../../settings/server';
import { Livechat } from '../../lib/Livechat';
import { getAgentOverviewDataCached, getAnalyticsOverviewDataCached } from '../../lib/AnalyticsTyped';

API.v1.addRoute(
'livechat/analytics/agent-overview',
Expand All @@ -22,7 +22,7 @@ API.v1.addRoute(

const user = await Users.findOneById(this.userId, { projection: { _id: 1, utcOffset: 1 } });
return API.v1.success(
await Livechat.Analytics.getAgentOverviewData({
await getAgentOverviewDataCached({
departmentId,
utcOffset: user?.utcOffset || 0,
daterange: { from, to },
Expand Down Expand Up @@ -52,7 +52,7 @@ API.v1.addRoute(
const language = user?.language || settings.get('Language') || 'en';

return API.v1.success(
await Livechat.Analytics.getAnalyticsOverviewData({
await getAnalyticsOverviewDataCached({
departmentId,
utcOffset: user?.utcOffset || 0,
daterange: { from, to },
Expand Down
Loading

0 comments on commit df2b989

Please sign in to comment.