Class: Crm::Reports::TechCallsReportController

Inherits:
CrmController
  • Object
show all
Includes:
Controllers::ReportCommandFlashable
Defined in:
app/controllers/crm/reports/tech_calls_report_controller.rb

Overview

Technical-support call report: tabbed breakdowns of call volume (total,
BPO redirected/not-redirected, CS/SR/AI/JB queues), each independently
sortable and paginated.

Constant Summary collapse

PER_PAGE =

Per page.

25
SORTABLE_COLUMNS =

Sortable columns.

%w[start_time origination full_name caller_id_number queue_name queue_extension outcome member_name talk_time].freeze

Instance Method Summary collapse

Instance Method Details

#showvoid

This method returns an undefined value.

Runs the tech-calls report command for the requested period, then sorts
and paginates the selected tab's records in memory.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/crm/reports/tech_calls_report_controller.rb', line 20

def show
  @report_command = ::Report::TechCallsReport::TechCallsReportCommand.new(tech_calls_report_command_params)
  @result = @report_command.execute
  @command_params = tech_calls_report_command_params.to_h.presence || {}

  if @result
    @tab      = params[:tab].presence || 'ttl'
    @page     = [params[:page].to_i, 1].max
    @per_page = PER_PAGE
    @sort_col = SORTABLE_COLUMNS.include?(params[:sort_col]) ? params[:sort_col] : 'start_time'
    @sort_dir = params[:sort_dir] == 'asc' ? 'asc' : 'desc'

    tab_records  = sorted_records(tab_data(@tab))
    @tab_total   = tab_records.size
    @tab_pages   = [(@tab_total.to_f / @per_page).ceil, 1].max
    @tab_records = tab_records.slice((@page - 1) * @per_page, @per_page) || []
  end

  flash_report_command_errors
  respond_to do |format|
    format.html
    format.turbo_stream
  end
end