Class: Athar::DashboardController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Athar::DashboardController
- Defined in:
- app/controllers/athar/dashboard_controller.rb
Constant Summary collapse
- PER_PAGE =
25
Instance Method Summary collapse
-
#index ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
Instance Method Details
#index ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/athar/dashboard_controller.rb', line 7 def index # rubocop:disable Metrics/AbcSize,Metrics/MethodLength @filters = Dashboard::FilterSet.from_params(params) @now = Time.current @registry = Dashboard::ModelRegistry.discover @registry_by_id = @registry.index_by { |model| [model.schema, model.table] } @selected_model = @registry.find { |model| model.record_type == @filters.model } if @filters.model feed_query = Dashboard::FeedQuery.new(filters: @filters, per_page: PER_PAGE, now: @now, registry: @registry) @rows = feed_query.call @total = feed_query.total @page = { current: @filters.page, last: [(@total.to_f / PER_PAGE).ceil, 1].max, total: @total, per_page: PER_PAGE } @actor_labels = resolve_actor_labels(@rows) @kpis = Dashboard::KpiCalculator.new(model: @filters.model, now: @now, registry: @registry).call @actors = Dashboard::ActorOptions.new(cutoff: @filters.time_cutoff(@now) || (@now - 30.days)).call @connection_info = Dashboard::ConnectionInfo.fetch end |