Class: Fosm::Admin::DashboardController

Inherits:
BaseController show all
Defined in:
app/controllers/fosm/admin/dashboard_controller.rb

Instance Method Summary collapse

Methods inherited from Fosm::ApplicationController

use_host_routes!

Instance Method Details

#indexObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/fosm/admin/dashboard_controller.rb', line 4

def index
  @apps = Fosm::Registry.all.map do |slug, model_class|
    lifecycle = model_class.fosm_lifecycle
    state_counts = lifecycle.state_names.index_with { |state_name|
      model_class.where(state: state_name).count
    }
    {
      slug: slug,
      model_class: model_class,
      name: model_class.name.demodulize.titleize,
      state_counts: state_counts,
      total: model_class.count,
      recent_transitions: Fosm::TransitionLog.for_app(model_class).recent.limit(3)
    }
  end

  @total_transitions = Fosm::TransitionLog.count
  @recent_transitions = Fosm::TransitionLog.recent.limit(10)
end