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.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 33 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
17 18 19 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 17 def by_depositor @by_depositor end |
#by_format ⇒ #query
17 18 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 17 attr_accessor :by_depositor, :by_format, :depositor_summary, :system_stats, :works_counter |
#depositor_summary ⇒ #depositors
17 18 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 17 attr_accessor :by_depositor, :by_format, :depositor_summary, :system_stats, :works_counter |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
4 5 6 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 4 def limit @limit end |
#stats_filters ⇒ Object (readonly)
Returns the value of attribute stats_filters.
4 5 6 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 4 def stats_filters @stats_filters end |
#system_stats ⇒ #recent_users
17 18 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 17 attr_accessor :by_depositor, :by_format, :depositor_summary, :system_stats, :works_counter |
#works_counter ⇒ #by_permission
17 18 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 17 attr_accessor :by_depositor, :by_format, :depositor_summary, :system_stats, :works_counter |
Instance Method Details
#active_users ⇒ Object
82 83 84 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 82 def active_users @active_users ||= by_depositor.query(limit: limit) end |
#date_filter_string ⇒ String
99 100 101 102 103 104 105 106 107 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 99 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
68 69 70 71 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 68 def depositors @depositors ||= depositor_summary.depositors(start_date: start_date, end_date: end_date) end |
#end_date ⇒ Object
54 55 56 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 54 def end_date @end_date ||= extract_date_from_stats_filters(key: :end_date, as_of: :end_of_day) end |
#recent_users ⇒ Object
74 75 76 77 78 79 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 74 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
50 51 52 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 50 def start_date @start_date ||= extract_date_from_stats_filters(key: :start_date, as_of: :beginning_of_day) end |
#top_formats ⇒ Object
87 88 89 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 87 def top_formats @top_formats ||= by_format.query(limit: limit) end |
#works_count ⇒ Object
92 93 94 95 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 92 def works_count @works_count ||= works_counter.(start_date: start_date, end_date: end_date) end |