Class: Admin::DashboardController

Inherits:
BaseController
  • Object
show all
Defined in:
vendor/plugins/dashboard/app/controllers/admin/dashboard_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'vendor/plugins/dashboard/app/controllers/admin/dashboard_controller.rb', line 3

def index
  @recent_activity = []
  
  Refinery::Plugins.active.each do |plugin|
    begin
      plugin.activity.each do |activity|
        include_associations = []
        include_associations.push(:slugs) if activity.class.methods.include? "find_one_with_friendly" # wee performance gain if slugs are used.

        @recent_activity += activity.class.find(:all,
          :conditions => activity.conditions,
          :order => activity.order,
          :limit => activity.limit,
          :include => include_associations
        )
      end
    rescue
      logger.info "#{$!.class.name} raised while getting recent activity for dashboard."
      logger.warn $!.backtrace.collect { |b| " > #{b}" }.join("\n")
    end
  end

  @recent_activity = @recent_activity.compact.uniq.sort{|x,y| y.updated_at <=> x.updated_at}[0..(RefinerySetting.find_or_set(:activity_show_limit, 15)-1)]
end