Module: Hyrax::UserUsageStats
- Defined in:
- app/models/concerns/hyrax/user_usage_stats.rb
Instance Method Summary collapse
- #stats ⇒ Object
- #total_file_downloads ⇒ Object
- #total_file_views ⇒ Object
- #total_work_views ⇒ Object
Instance Method Details
#stats ⇒ Object
2 3 4 |
# File 'app/models/concerns/hyrax/user_usage_stats.rb', line 2 def stats @stats ||= UserStat.where(user_id: id).order(date: :asc) end |
#total_file_downloads ⇒ Object
10 11 12 |
# File 'app/models/concerns/hyrax/user_usage_stats.rb', line 10 def total_file_downloads stats.reduce(0) { |total, stat| total + stat.file_downloads } end |
#total_file_views ⇒ Object
6 7 8 |
# File 'app/models/concerns/hyrax/user_usage_stats.rb', line 6 def total_file_views stats.reduce(0) { |total, stat| total + stat.file_views } end |
#total_work_views ⇒ Object
14 15 16 |
# File 'app/models/concerns/hyrax/user_usage_stats.rb', line 14 def total_work_views stats.reduce(0) { |total, stat| total + stat.work_views } end |