Module: Hyrax::UserUsageStats

Defined in:
app/models/concerns/hyrax/user_usage_stats.rb

Instance Method Summary collapse

Instance Method Details

#statsObject



3
4
5
# File 'app/models/concerns/hyrax/user_usage_stats.rb', line 3

def stats
  @stats ||= UserStat.where(user_id: id).order(date: :asc)
end

#total_file_downloadsObject



11
12
13
# File 'app/models/concerns/hyrax/user_usage_stats.rb', line 11

def total_file_downloads
  stats.reduce(0) { |total, stat| total + stat.file_downloads }
end

#total_file_viewsObject



7
8
9
# File 'app/models/concerns/hyrax/user_usage_stats.rb', line 7

def total_file_views
  stats.reduce(0) { |total, stat| total + stat.file_views }
end

#total_work_viewsObject



15
16
17
# File 'app/models/concerns/hyrax/user_usage_stats.rb', line 15

def total_work_views
  stats.reduce(0) { |total, stat| total + stat.work_views }
end