Class: Crm::Reports::MissedCallsController

Inherits:
CrmController
  • Object
show all
Defined in:
app/controllers/crm/reports/missed_calls_controller.rb

Constant Summary collapse

ITEMS_PER_PAGE =
50

Instance Method Summary collapse

Instance Method Details

#showObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/crm/reports/missed_calls_controller.rb', line 6

def show
  @report_command = ::Report::MissedCalls::MissedCallsCommand.new(params[:command])
  @result = @report_command.execute

  if @report_command.success? && @result&.data&.present?
    unfiltered = @report_command.unfiltered_data
    @completed_count     = unfiltered.where(result_type: 'completed').count
    @not_completed_count = unfiltered.where.not(result_type: 'completed').count
    @queue_counts        = @result.data.group(:queue_name).count.sort_by { |_, v| -v }.to_h
    @pagy, @paginated_data = pagy(:offset, @result.data, limit: ITEMS_PER_PAGE)
  end

  respond_to do |format|
    format.html
  end
end