Class: Admin::ServiceErrorsController

Inherits:
UmlautController show all
Defined in:
app/controllers/admin/service_errors_controller.rb

Instance Method Summary collapse

Methods included from Umlaut::ControllerBehavior

#default_url_options, #set_locale

Methods included from UmlautConfigurable

set_default_configuration!

Instance Method Details

#indexObject


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/admin/service_errors_controller.rb', line 18

def index
  # grab the earliest dispatch to see how far back our db goes
  @earliest_dispatch = DispatchedService.select("updated_at").
    order("updated_at").
    limit(1).
    first.
    updated_at
  
  
  errors_base = DispatchedService.
    where(:status => [DispatchedService::FailedFatal, DispatchedService::FailedTemporary])
  
  if params[:service_id]
    errors_base = errors_base.where(:service_id => params[:service_id])
  end
  
  if params[:q]
    errors_base = errors_base.where("exception_info #{" NOT " if params[:q_not]} like ?", "%#{params[:q]}%")
  end
  
  # will miraculously return a hash whose key is service_id, value
  # is count of failed service dispatches. 
  @failed_by_service = errors_base.select("service_id").        
    group("service_id").
    count
  
  # And get the most recent batch of failed services
  # kaminari page/per
  @offset = params[:offset].to_i 
  @limit = params[:per_page].to_i 
  @limit = 10 if @limit == 0
  
  @dispatched_services = errors_base.order("updated_at DESC").
    limit(@limit).offset(@offset)             
  @dispatched_services_count = errors_base.count
end