inbox view
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
class V2::Reports::InboxSummaryBuilder < V2::Reports::BaseSummaryBuilder
|
||||
pattr_initialize [:account!, :params!]
|
||||
|
||||
def build
|
||||
set_grouped_conversations_count
|
||||
set_grouped_resolved_conversations_count
|
||||
set_grouped_avg_reply_time
|
||||
set_grouped_avg_first_response_time
|
||||
set_grouped_avg_resolution_time
|
||||
prepare_report
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_grouped_conversations_count
|
||||
@grouped_conversations_count = Current.account.conversations.where(created_at: range).group('inbox_id').count
|
||||
end
|
||||
|
||||
def set_grouped_avg_resolution_time
|
||||
@grouped_avg_resolution_time = get_grouped_average(reporting_events.where(name: 'conversation_resolved'))
|
||||
end
|
||||
|
||||
def set_grouped_avg_first_response_time
|
||||
@grouped_avg_first_response_time = get_grouped_average(reporting_events.where(name: 'first_response'))
|
||||
end
|
||||
|
||||
def set_grouped_avg_reply_time
|
||||
@grouped_avg_reply_time = get_grouped_average(reporting_events.where(name: 'reply_time'))
|
||||
end
|
||||
|
||||
def set_grouped_resolved_conversations_count
|
||||
@grouped_resolved_conversations_count = reporting_events.where(name: 'conversation_resolved').group(group_by_key).count
|
||||
end
|
||||
|
||||
def group_by_key
|
||||
:inbox_id
|
||||
end
|
||||
|
||||
def reporting_events
|
||||
@reporting_events ||= Current.account.reporting_events.where(created_at: range)
|
||||
end
|
||||
|
||||
def prepare_report
|
||||
account.inboxes.each_with_object([]) do |inbox, arr|
|
||||
inbox_id = inbox.id
|
||||
arr << {
|
||||
id: inbox_id,
|
||||
conversations_count: @grouped_conversations_count[inbox_id],
|
||||
resolved_conversations_count: @grouped_resolved_conversations_count[inbox_id],
|
||||
avg_resolution_time: @grouped_avg_resolution_time[inbox_id],
|
||||
avg_first_response_time: @grouped_avg_first_response_time[inbox_id],
|
||||
avg_reply_time: @grouped_avg_reply_time[inbox_id]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def average_value_key
|
||||
ActiveModel::Type::Boolean.new.cast(params[:business_hours]).present? ? :value_in_business_hours : :value
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
class Api::V2::Accounts::SummaryReportsController < Api::V1::Accounts::BaseController
|
||||
before_action :check_authorization
|
||||
before_action :prepare_builder_params, only: [:agent, :team]
|
||||
before_action :prepare_builder_params, only: [:agent, :team, :inbox]
|
||||
|
||||
def agent
|
||||
render_report_with(V2::Reports::AgentSummaryBuilder)
|
||||
@@ -10,6 +10,10 @@ class Api::V2::Accounts::SummaryReportsController < Api::V1::Accounts::BaseContr
|
||||
render_report_with(V2::Reports::TeamSummaryBuilder)
|
||||
end
|
||||
|
||||
def inbox
|
||||
render_report_with(V2::Reports::InboxSummaryBuilder)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_authorization
|
||||
|
||||
@@ -25,6 +25,16 @@ class SummaryReportsAPI extends ApiClient {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getInboxReports({ since, until, businessHours } = {}) {
|
||||
return axios.get(`${this.url}/inbox`, {
|
||||
params: {
|
||||
since,
|
||||
until,
|
||||
business_hours: businessHours,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default new SummaryReportsAPI();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</metric-card>
|
||||
<metric-card
|
||||
:is-live="false"
|
||||
header="Agentwise reports"
|
||||
header="Agent-wise reports"
|
||||
class="overflow-visible"
|
||||
>
|
||||
<woot-reports
|
||||
|
||||
@@ -1,19 +1,46 @@
|
||||
<template>
|
||||
<woot-reports
|
||||
key="inbox-reports"
|
||||
type="inbox"
|
||||
getter-key="inboxes/getInboxes"
|
||||
action-key="inboxes/get"
|
||||
:download-button-label="$t('INBOX_REPORTS.DOWNLOAD_INBOX_REPORTS')"
|
||||
/>
|
||||
<div class="column overflow-auto">
|
||||
<metric-card :is-live="false" header="All inboxes overview">
|
||||
<woot-summary-reports
|
||||
key="inbox-view-reports"
|
||||
class="!p-0"
|
||||
type="inbox"
|
||||
getter-key="inboxes/getInboxes"
|
||||
action-key="summaryReports/fetchInboxSummaryReports"
|
||||
summary-key="summaryReports/getInboxSummaryReports"
|
||||
:download-button-label="$t('INBOX_REPORTS.DOWNLOAD_INBOX_REPORTS')"
|
||||
/>
|
||||
</metric-card>
|
||||
<metric-card
|
||||
:is-live="false"
|
||||
header="Inbox-wise reports"
|
||||
class="overflow-visible"
|
||||
>
|
||||
<woot-reports
|
||||
key="inbox-reports"
|
||||
:show-download-button="false"
|
||||
class="!p-0"
|
||||
type="inbox"
|
||||
getter-key="inboxes/getInboxes"
|
||||
action-key="inboxes/get"
|
||||
/>
|
||||
</metric-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import WootSummaryReports from './components/WootSummaryReports.vue';
|
||||
import MetricCard from './components/overview/MetricCard.vue';
|
||||
import WootReports from './components/WootReports.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
WootReports,
|
||||
MetricCard,
|
||||
WootSummaryReports,
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch('agents/get');
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</metric-card>
|
||||
<metric-card
|
||||
:is-live="false"
|
||||
header="Teamwise reports"
|
||||
header="Team-wise reports"
|
||||
class="overflow-visible"
|
||||
>
|
||||
<woot-reports
|
||||
|
||||
@@ -4,6 +4,7 @@ import Vue from 'vue';
|
||||
export const state = {
|
||||
teamSummaryReports: [],
|
||||
agentSummaryReports: [],
|
||||
inboxSummaryReports: [],
|
||||
uiFlags: {},
|
||||
};
|
||||
|
||||
@@ -14,6 +15,9 @@ export const getters = {
|
||||
getTeamSummaryReports(_state) {
|
||||
return _state.teamSummaryReports;
|
||||
},
|
||||
getInboxSummaryReports(_state) {
|
||||
return _state.inboxSummaryReports;
|
||||
},
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
@@ -33,6 +37,14 @@ export const actions = {
|
||||
// Ignore error
|
||||
}
|
||||
},
|
||||
async fetchInboxSummaryReports({ commit }, params) {
|
||||
try {
|
||||
const response = await SummaryReportsAPI.getInboxReports(params);
|
||||
commit('setInboxSummaryReport', response.data);
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const mutations = {
|
||||
@@ -42,6 +54,9 @@ export const mutations = {
|
||||
setAgentSummaryReport(_state, data) {
|
||||
Vue.set(_state, 'agentSummaryReports', data);
|
||||
},
|
||||
setInboxSummaryReport(_state, data) {
|
||||
Vue.set(_state, 'inboxSummaryReports', data);
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
@@ -304,6 +304,7 @@ Rails.application.routes.draw do
|
||||
collection do
|
||||
get :agent
|
||||
get :team
|
||||
get :inbox
|
||||
end
|
||||
end
|
||||
resources :reports, only: [:index] do
|
||||
|
||||
Reference in New Issue
Block a user