Class: Hyrax::AdminStatsPresenter
- Inherits:
-
Object
- Object
- Hyrax::AdminStatsPresenter
- Defined in:
- app/presenters/hyrax/admin_stats_presenter.rb
Instance Attribute Summary collapse
- #by_depositor ⇒ #query
- #by_format ⇒ #query
- #depositor_summary ⇒ #depositors
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#stats_filters ⇒ Object
readonly
Returns the value of attribute stats_filters.
- #system_stats ⇒ #recent_users
- #works_counter ⇒ #by_permission
Instance Method Summary collapse
- #active_users ⇒ Object
- #date_filter_string ⇒ String
- #depositors ⇒ Object
- #end_date ⇒ Object
-
#initialize(stats_filters, limit, by_depositor: Hyrax::Statistics::Works::ByDepositor, by_format: Hyrax::Statistics::FileSets::ByFormat, depositor_summary: Hyrax::Statistics::Depositors::Summary, system_stats: Hyrax::Statistics::SystemStats, works_counter: Hyrax::Statistics::Works::Count) ⇒ AdminStatsPresenter
constructor
A new instance of AdminStatsPresenter.
- #recent_users ⇒ Object
-
#start_date ⇒ Object
rubocop:enable Metrics/ParameterLists.
- #top_formats ⇒ Object
- #works_count ⇒ Object
Constructor Details
#initialize(stats_filters, limit, by_depositor: Hyrax::Statistics::Works::ByDepositor, by_format: Hyrax::Statistics::FileSets::ByFormat, depositor_summary: Hyrax::Statistics::Depositors::Summary, system_stats: Hyrax::Statistics::SystemStats, works_counter: Hyrax::Statistics::Works::Count) ⇒ AdminStatsPresenter
Returns a new instance of AdminStatsPresenter.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 32 def initialize(stats_filters, limit, by_depositor: Hyrax::Statistics::Works::ByDepositor, by_format: Hyrax::Statistics::FileSets::ByFormat, depositor_summary: Hyrax::Statistics::Depositors::Summary, system_stats: Hyrax::Statistics::SystemStats, works_counter: Hyrax::Statistics::Works::Count) @stats_filters = stats_filters @limit = limit self.by_depositor = by_depositor self.by_format = by_format self.depositor_summary = depositor_summary self.system_stats = system_stats self.works_counter = works_counter end |
Instance Attribute Details
#by_depositor ⇒ #query
16 17 18 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 16 def by_depositor @by_depositor end |
#by_format ⇒ #query
16 17 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 16 attr_accessor :by_depositor, :by_format, :depositor_summary, :system_stats, :works_counter |
#depositor_summary ⇒ #depositors
16 17 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 16 attr_accessor :by_depositor, :by_format, :depositor_summary, :system_stats, :works_counter |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
3 4 5 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 3 def limit @limit end |
#stats_filters ⇒ Object (readonly)
Returns the value of attribute stats_filters.
3 4 5 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 3 def stats_filters @stats_filters end |
#system_stats ⇒ #recent_users
16 17 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 16 attr_accessor :by_depositor, :by_format, :depositor_summary, :system_stats, :works_counter |
#works_counter ⇒ #by_permission
16 17 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 16 attr_accessor :by_depositor, :by_format, :depositor_summary, :system_stats, :works_counter |
Instance Method Details
#active_users ⇒ Object
81 82 83 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 81 def active_users @active_users ||= by_depositor.query(limit: limit) end |
#date_filter_string ⇒ String
98 99 100 101 102 103 104 105 106 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 98 def date_filter_string if start_date.blank? "unfiltered" elsif end_date.blank? "#{start_date.to_date.to_formatted_s(:standard)} to #{Date.current.to_formatted_s(:standard)}" else "#{start_date.to_date.to_formatted_s(:standard)} to #{end_date.to_date.to_formatted_s(:standard)}" end end |
#depositors ⇒ Object
67 68 69 70 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 67 def depositors @depositors ||= depositor_summary.depositors(start_date: start_date, end_date: end_date) end |
#end_date ⇒ Object
53 54 55 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 53 def end_date @end_date ||= extract_date_from_stats_filters(key: :end_date, as_of: :end_of_day) end |
#recent_users ⇒ Object
73 74 75 76 77 78 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 73 def recent_users @recent_users ||= system_stats.recent_users(limit: limit, start_date: start_date, end_date: end_date) end |
#start_date ⇒ Object
rubocop:enable Metrics/ParameterLists
49 50 51 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 49 def start_date @start_date ||= extract_date_from_stats_filters(key: :start_date, as_of: :beginning_of_day) end |
#top_formats ⇒ Object
86 87 88 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 86 def top_formats @top_formats ||= by_format.query(limit: limit) end |
#works_count ⇒ Object
91 92 93 94 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 91 def works_count @works_count ||= works_counter.(start_date: start_date, end_date: end_date) end |