Sha256: 2f93e0ff33a8bbb3d9aa297cbf626290fd8cb752f51c5f5497fd1013ee1326f0

Contents?: true

Size: 1.53 KB

Versions: 29

Compression:

Stored size: 1.53 KB

Contents

module Hyrax
  module Admin
    ##
    # @example using a custom presenter and stats services
    #   class MyStatsController < ApplicationController
    #     include Hyrax::Admin::StatsBehavior
    #
    #     self.admin_stats_presenter = MyCustomStatsPresenter
    #     self.admin_stats_services = { by_depositor:      CustomDepositorService,
    #                                   depositor_summary: CustomSummaryService }
    #     # see AdminStatsPresenter#initialize for supported services
    #   end
    #
    module StatsBehavior
      extend ActiveSupport::Concern
      included do
        with_themed_layout 'dashboard'

        class_attribute :admin_stats_presenter, :admin_stats_services
        self.admin_stats_presenter = AdminStatsPresenter
        self.admin_stats_services  = {}
      end

      def show
        authorize! :read, Hyrax::Statistics
        stats_filters = params.fetch(:stats_filters, {})
        limit = params.fetch(:limit, "5").to_i
        @presenter = build_presenter(stats_filters, limit)
        add_breadcrumb t(:'hyrax.controls.home'), root_path
        add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
        add_breadcrumb t(:'hyrax.admin.sidebar.statistics'), hyrax.admin_stats_path
      end

      private

        def build_presenter(stats_filters, limit)
          presenter_class = self.class.admin_stats_presenter
          services_opts   = self.class.admin_stats_services

          presenter_class.new(stats_filters, limit, **services_opts)
        end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.9.5 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.9.4 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.9.3 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.9.2 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.9.1 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.9.0 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.8.0 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.7.2 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.7.1 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.7.0 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.6.0 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-3.0.0.pre.rc1 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-3.0.0.pre.beta3 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.5.1 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.5.0 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-3.0.0.pre.beta2 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.4.1 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-3.0.0.pre.beta1 app/controllers/concerns/hyrax/admin/stats_behavior.rb
hyrax-2.4.0 app/controllers/concerns/hyrax/admin/stats_behavior.rb