Class: Api::V1::StatsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/api/v1/stats_controller.rb

Instance Method Summary collapse

Instance Method Details

#appObject


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/api/v1/stats_controller.rb', line 8

def app
  if problem = @app.problems.order_by(:last_notice_at.desc).first
    @last_error_time = problem.last_notice_at
  end

  stats = {
    :name => @app.name,
    :id => @app.id,
    :last_error_time => @last_error_time,
    :unresolved_errors => @app.unresolved_count
  }

  respond_to do |format|
    format.any(:html, :json) { render :json => JSON.dump(stats) } # render JSON if no extension specified on path
    format.xml  { render :xml  => stats }
  end
end