diff --git a/app/builders/v2/reports/inbox_summary_builder.rb b/app/builders/v2/reports/inbox_summary_builder.rb
new file mode 100644
index 000000000..ae7ca4954
--- /dev/null
+++ b/app/builders/v2/reports/inbox_summary_builder.rb
@@ -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
diff --git a/app/controllers/api/v2/accounts/summary_reports_controller.rb b/app/controllers/api/v2/accounts/summary_reports_controller.rb
index 0cbd6dd8e..47d32a452 100644
--- a/app/controllers/api/v2/accounts/summary_reports_controller.rb
+++ b/app/controllers/api/v2/accounts/summary_reports_controller.rb
@@ -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
diff --git a/app/javascript/dashboard/api/summaryReports.js b/app/javascript/dashboard/api/summaryReports.js
index e1ea73038..f772ef86f 100644
--- a/app/javascript/dashboard/api/summaryReports.js
+++ b/app/javascript/dashboard/api/summaryReports.js
@@ -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();
diff --git a/app/javascript/dashboard/routes/dashboard/settings/reports/AgentReports.vue b/app/javascript/dashboard/routes/dashboard/settings/reports/AgentReports.vue
index fec788fd0..eb9b09880 100644
--- a/app/javascript/dashboard/routes/dashboard/settings/reports/AgentReports.vue
+++ b/app/javascript/dashboard/routes/dashboard/settings/reports/AgentReports.vue
@@ -14,7 +14,7 @@
-
+
+
+
+
+
+
+
+
diff --git a/app/javascript/dashboard/routes/dashboard/settings/reports/TeamReports.vue b/app/javascript/dashboard/routes/dashboard/settings/reports/TeamReports.vue
index 906f4be23..c93ef6d12 100644
--- a/app/javascript/dashboard/routes/dashboard/settings/reports/TeamReports.vue
+++ b/app/javascript/dashboard/routes/dashboard/settings/reports/TeamReports.vue
@@ -14,7 +14,7 @@