Class: Hyrax::Statistics::SystemStats
- Inherits:
-
Object
- Object
- Hyrax::Statistics::SystemStats
- Defined in:
- app/services/hyrax/statistics/system_stats.rb
Overview
A class that retrieves system level statistics about the system TODO: this class could be refactored into several classes.
Instance Attribute Summary collapse
-
#end_date ⇒ Time
readonly
Filters the statistics returned by the class to before end date nil means today.
-
#limit ⇒ Integer
readonly
limits the results returned from top_depositors and top_formats Default is 5, maximum is 20, minimum is 5.
-
#start_date ⇒ Time
readonly
Filters the statistics returned by the class to after the start date nil means no filter.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(limit_records = 5, start_date = nil, end_date = nil) ⇒ SystemStats
constructor
A new instance of SystemStats.
-
#recent_users ⇒ Object
returns [Array<user>] a list (of size limit) of users most recently registered with the system.
-
#top_depositors ⇒ Hash
returns a list (of size limit) of system users (depositors) that have the most deposits in the system.
Constructor Details
#initialize(limit_records = 5, start_date = nil, end_date = nil) ⇒ SystemStats
Returns a new instance of SystemStats.
27 28 29 30 31 |
# File 'app/services/hyrax/statistics/system_stats.rb', line 27 def initialize(limit_records = 5, start_date = nil, end_date = nil) @limit = validate_limit(limit_records) @start_date = start_date @end_date = end_date end |
Instance Attribute Details
#end_date ⇒ Time (readonly)
Filters the statistics returned by the class to before end date nil means today
12 13 14 |
# File 'app/services/hyrax/statistics/system_stats.rb', line 12 def end_date @end_date end |
#limit ⇒ Integer (readonly)
limits the results returned from top_depositors and top_formats Default is 5, maximum is 20, minimum is 5
12 13 14 |
# File 'app/services/hyrax/statistics/system_stats.rb', line 12 def limit @limit end |
#start_date ⇒ Time (readonly)
Filters the statistics returned by the class to after the start date nil means no filter
12 13 14 |
# File 'app/services/hyrax/statistics/system_stats.rb', line 12 def start_date @start_date end |
Class Method Details
.recent_users(limit: 5, start_date: nil, end_date: nil) ⇒ Array<User>
20 21 22 |
# File 'app/services/hyrax/statistics/system_stats.rb', line 20 def self.recent_users(limit: 5, start_date: nil, end_date: nil) new(limit, start_date, end_date).recent_users end |
Instance Method Details
#recent_users ⇒ Object
returns [Array<user>] a list (of size limit) of users most recently registered with the system
44 45 46 47 48 49 |
# File 'app/services/hyrax/statistics/system_stats.rb', line 44 def recent_users # no dates return the top few based on limit return ::User.order('created_at DESC').limit(limit) if start_date.blank? ::User.recent_users start_date, end_date end |