Class: SpeedupDashboard::RequestsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/speedup_dashboard/requests_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authorize_server, #find_optional_server, #render_403, #render_error

Instance Method Details

#createObject



40
41
42
43
44
45
46
47
48
# File 'app/controllers/speedup_dashboard/requests_controller.rb', line 40

def create
  @request = SpeedupDashboard::RequestStore.new(params[:request_id])
  @request.load(params[:contexts], params[:data])
  @request.save

  respond_to do |format|
    format.json { render nothing: true}
  end
end

#indexObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/speedup_dashboard/requests_controller.rb', line 14

def index
  scope = (@server && @server.requests)
  scope ||= Request.all

  @from = Time.now - 5.days
  @to = Time.now
  @requests = scope.between(@from, @to)
  if params[:c] && params[:a]
    @action = "#{params[:c]}##{params[:a]}"
    @requests = @requests.where(controller: params[:c], action: params[:a])
  end

  if @context = params[:context]
    @context_data = Context.where(name: @context, request_id: @requests)
  else
    @errors_count = @requests.errors.count
    @error_rate = @requests.count > 0 ? ((@errors_count.to_f / @requests.count) * 10000).round.to_f / 100 : 0
  end

  render "speedup_dashboard/contexts/#{@context}" if @context
end

#showObject



36
37
38
# File 'app/controllers/speedup_dashboard/requests_controller.rb', line 36

def show
  @request = Request.find(params[:id])
end