Class: Hyrax::AdminStatsPresenter
- Inherits:
-
Object
- Object
- Hyrax::AdminStatsPresenter
- Defined in:
- app/presenters/hyrax/admin_stats_presenter.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#stats_filters ⇒ Object
readonly
Returns the value of attribute stats_filters.
Instance Method Summary collapse
- #active_users ⇒ Object
- #date_filter_string ⇒ Object
- #depositors ⇒ Object
- #end_date ⇒ Object
-
#initialize(stats_filters, limit) ⇒ AdminStatsPresenter
constructor
A new instance of AdminStatsPresenter.
- #recent_users ⇒ Object
- #start_date ⇒ Object
- #top_formats ⇒ Object
- #works_count ⇒ Object
Constructor Details
#initialize(stats_filters, limit) ⇒ AdminStatsPresenter
Returns a new instance of AdminStatsPresenter.
5 6 7 8 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 5 def initialize(stats_filters, limit) @stats_filters = stats_filters @limit = limit end |
Instance Attribute Details
#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 |
Instance Method Details
#active_users ⇒ Object
26 27 28 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 26 def active_users @active_users ||= Hyrax::Statistics::Works::ByDepositor.new(limit).query end |
#date_filter_string ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 38 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
18 19 20 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 18 def depositors @depositors ||= Hyrax::Statistics::Depositors::Summary.new(start_date, end_date).depositors end |
#end_date ⇒ Object
14 15 16 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 14 def end_date @end_date ||= Time.zone.parse(stats_filters[:end_date]).end_of_day if stats_filters[:end_date].present? end |
#recent_users ⇒ Object
22 23 24 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 22 def recent_users @recent_users ||= stats.recent_users end |
#start_date ⇒ Object
10 11 12 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 10 def start_date @start_date ||= Time.zone.parse(stats_filters[:start_date]).beginning_of_day if stats_filters[:start_date].present? end |
#top_formats ⇒ Object
30 31 32 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 30 def top_formats @top_formats ||= Hyrax::Statistics::FileSets::ByFormat.new(limit).query end |
#works_count ⇒ Object
34 35 36 |
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 34 def works_count @works_count ||= Hyrax::Statistics::Works::Count.new(start_date, end_date). end |