Class: Tnw::DashboardController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tnw/dashboard_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
11
12
# File 'app/controllers/tnw/dashboard_controller.rb', line 3

def index
  servers = Tnw::Server.order(:name, :identifier)
  latest_samples = Tnw::MetricSample
    .where(id: Tnw::MetricSample.select("MAX(id)").group(:server_id))
    .index_by(&:server_id)

  @server_metrics = servers.map do |server|
    Tnw::ServerMetricStatus.new(server: server, sample: latest_samples[server.id])
  end
end