fix: Update agent metrics query to show data from current account (#4557)
* Update agent metrics query to fetch data from current account
This commit is contained in:
@@ -4,7 +4,7 @@ class V2::ReportBuilder
|
||||
attr_reader :account, :params
|
||||
|
||||
DEFAULT_GROUP_BY = 'day'.freeze
|
||||
AGENT_RESULTS_PER_PAGE = 10
|
||||
AGENT_RESULTS_PER_PAGE = 25
|
||||
|
||||
def initialize(account, params)
|
||||
@account = account
|
||||
@@ -46,7 +46,7 @@ class V2::ReportBuilder
|
||||
if params[:type].equal?(:account)
|
||||
conversations
|
||||
else
|
||||
agent_metrics
|
||||
agent_metrics.sort_by { |hash| hash[:metric][:open] }.reverse
|
||||
end
|
||||
end
|
||||
|
||||
@@ -95,10 +95,10 @@ class V2::ReportBuilder
|
||||
end
|
||||
|
||||
def conversations
|
||||
@open_conversations = scope.conversations.open
|
||||
@open_conversations = scope.conversations.where(account_id: @account.id).open
|
||||
first_response_count = scope.reporting_events.where(name: 'first_response', conversation_id: @open_conversations.pluck('id')).count
|
||||
metric = {
|
||||
total: @open_conversations.count,
|
||||
open: @open_conversations.count,
|
||||
unattended: @open_conversations.count - first_response_count
|
||||
}
|
||||
metric[:unassigned] = @open_conversations.unassigned.count if params[:type].equal?(:account)
|
||||
|
||||
@@ -387,18 +387,18 @@
|
||||
"LIVE": "Live",
|
||||
"ACCOUNT_CONVERSATIONS": {
|
||||
"HEADER": "Open Conversations",
|
||||
"LOADING_MESSAGE": "Conversations Loading...",
|
||||
"TOTAL" : "Total",
|
||||
"LOADING_MESSAGE": "Loading conversation metrics...",
|
||||
"OPEN" : "Open",
|
||||
"UNATTENDED": "Unattended",
|
||||
"UNASSIGNED": "Unassigned"
|
||||
},
|
||||
"AGENT_CONVERSATIONS": {
|
||||
"HEADER": "Conversations by agents",
|
||||
"LOADING_MESSAGE": "Agents Loading...",
|
||||
"LOADING_MESSAGE": "Loading agent metrics...",
|
||||
"NO_AGENTS": "There are no conversations by agents",
|
||||
"TABLE_HEADER": {
|
||||
"AGENT": "Agent",
|
||||
"TOTAL": "Total",
|
||||
"OPEN": "OPEN",
|
||||
"UNATTENDED": "Unattended",
|
||||
"STATUS": "Status"
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
<ve-pagination
|
||||
:total="totalAgents"
|
||||
:page-index="pageIndex"
|
||||
:page-size="10"
|
||||
:page-size-option="[10]"
|
||||
:page-size="25"
|
||||
:page-size-option="[25]"
|
||||
@on-page-number-change="onPageNumberChange"
|
||||
/>
|
||||
</div>
|
||||
@@ -70,7 +70,7 @@ export default {
|
||||
agent: agent.name,
|
||||
email: agent.email,
|
||||
thumbnail: agent.thumbnail,
|
||||
total: agent.metric.total || 0,
|
||||
open: agent.metric.open || 0,
|
||||
unattended: agent.metric.unattended || 0,
|
||||
status: agent.availability,
|
||||
};
|
||||
@@ -103,10 +103,10 @@ export default {
|
||||
),
|
||||
},
|
||||
{
|
||||
field: 'total',
|
||||
key: 'total',
|
||||
field: 'open',
|
||||
key: 'open',
|
||||
title: this.$t(
|
||||
'OVERVIEW_REPORTS.AGENT_CONVERSATIONS.TABLE_HEADER.TOTAL'
|
||||
'OVERVIEW_REPORTS.AGENT_CONVERSATIONS.TABLE_HEADER.OPEN'
|
||||
),
|
||||
align: 'left',
|
||||
width: 10,
|
||||
|
||||
@@ -123,7 +123,7 @@ export const METRIC_CHART = {
|
||||
};
|
||||
|
||||
export const OVERVIEW_METRICS = {
|
||||
total: 'TOTAL',
|
||||
open: 'OPEN',
|
||||
unattended: 'UNATTENDED',
|
||||
unassigned: 'UNASSIGNED',
|
||||
online: 'ONLINE',
|
||||
|
||||
Reference in New Issue
Block a user