Project

General

Profile

« Previous | Next » 

Revision fee0b7af

Added by Ohad Levy almost 14 years ago

  • ID fee0b7af72064c5cfe457c1e29e3b67d7b904194

Minor SQL optimization to hosts page

View differences:

app/controllers/hosts_controller.rb
def index
@search = Host.search(params[:search])
@hosts = @search.paginate :page => params[:page]
@hosts = @search.paginate :page => params[:page], :include => [:hostgroup, :domain, :operatingsystem, :environment]
@via = "fact_values_"
@last_reports = Report.maximum(:id, :group => :host_id, :conditions => {:host_id => @hosts})
end
def show
app/helpers/hosts_helper.rb
return nil if record.last_report.nil?
time = time_ago_in_words(record.last_report.getlocal)
image_tag("#{not (record.error_count > 0 or record.no_report)}.png", :size => "18x18") +
link_to_if(Report.maximum('id', :conditions => {:host_id => record.id}), time, report_host_path(record))
link_to_if(@last_reports[record.id], time, report_path(@last_reports[record.id].to_i))
end
# method that reformats the hostname column by adding the status icons

Also available in: Unified diff