The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/app/livechat/server/lib/analytics/agents.js

52 lines
1.9 KiB

import { LivechatRooms, LivechatAgentActivity } from '../../../../models/server/raw';
const findAllAverageServiceTimeAsync = async ({
start,
end,
options = {},
}) => {
if (!start || !end) {
throw new Error('"start" and "end" must be provided');
}
const total = await LivechatRooms.findAllAverageServiceTimeByAgents({ start, end, onlyCount: true }).toArray();
return {
agents: await LivechatRooms.findAllAverageServiceTimeByAgents({ start, end, options }).toArray(),
total: total.length ? total[0].total : 0,
};
};
const findAllServiceTimeAsync = async ({
start,
end,
options = {},
}) => {
if (!start || !end) {
throw new Error('"start" and "end" must be provided');
}
const total = await LivechatRooms.findAllServiceTimeByAgent({ start, end, onlyCount: true }).toArray();
return {
agents: await LivechatRooms.findAllServiceTimeByAgent({ start, end, options }).toArray(),
total: total.length ? total[0].total : 0,
};
};
const findAvailableServiceTimeHistoryAsync = async ({
start,
end,
fullReport,
options = {},
}) => {
if (!start || !end) {
throw new Error('"start" and "end" must be provided');
}
const total = await LivechatAgentActivity.findAvailableServiceTimeHistory({ start, end, fullReport, onlyCount: true }).toArray();
return {
agents: await LivechatAgentActivity.findAvailableServiceTimeHistory({ start, end, fullReport, options }).toArray(),
total: total.length ? total[0].total : 0,
};
};
export const findAllAverageServiceTime = ({ start, end, options }) => Promise.await(findAllAverageServiceTimeAsync({ start, end, options }));
export const findAllServiceTime = ({ start, end, options }) => Promise.await(findAllServiceTimeAsync({ start, end, options }));
export const findAvailableServiceTimeHistory = ({ start, end, fullReport, options }) => Promise.await(findAvailableServiceTimeHistoryAsync({ start, end, fullReport, options }));