Skip to content

Commit

Permalink
Fixes #10879 - improved reports widget performance
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap committed Jun 22, 2015
1 parent b95c1e1 commit 3aa9843
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/helpers/dashboard_helper.rb
Expand Up @@ -59,8 +59,8 @@ def searchable_links(name, search, counter)
end

def latest_events
# 6 reports + header fits the events box nicely...
Report.authorized(:view_reports).my_reports.interesting.search_for('reported > "7 days ago"').limit(6).includes(:host)
# scoped_search generates unoptimized query until this is fixed: https://github.com/wvanbergen/scoped_search/pull/132
Report.authorized(:view_reports).my_reports.interesting.where("reported_at > ?", 7.days.ago).order("reported_at DESC").limit(6).includes(:host)
end

def translated_header(shortname, longname)
Expand Down
10 changes: 10 additions & 0 deletions db/migrate/20150622090115_change_reported_at.rb
@@ -0,0 +1,10 @@
class ChangeReportedAt < ActiveRecord::Migration
def up
Report.where(:reported_at => nil).update_all(:reported_at => Time.at(0))
change_column :reports, :reported_at, :datetime, :null => false
end

def down
change_column :reports, :reported_at, :datetime, :null => true
end
end

0 comments on commit 3aa9843

Please sign in to comment.