Skip to content

Commit

Permalink
Adds required includes to user_stat_importer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Scherz committed Feb 14, 2018
1 parent f772666 commit dd2f780
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions app/services/hyrax/user_stat_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,8 @@
require Hyrax::Engine.root.join('app/services/hyrax/user_stat_importer.rb')
module Hyrax
class UserStatImporter
private

def process_files(stats, user, start_date)
file_ids_for_user(user).each do |file_id|
file = ::FileSet.find(file_id)
view_stats = rescue_and_retry("Retried FileViewStat on #{user} for file #{file_id} too many times.") { FileViewStat.statistics(file, start_date, user.id) }
stats = tally_results(view_stats, :views, stats) unless (view_stats.blank? || view_stats)
delay
dl_stats = rescue_and_retry("Retried FileDownloadStat on #{user} for file #{file_id} too many times.") { FileDownloadStat.statistics(file, start_date, user.id) }
stats = tally_results(dl_stats, :downloads, stats) unless (dl_stats.blank? || dl_stats)
delay
end
end

def process_works(stats, user, start_date)
work_ids_for_user(user).each do |work_id|
work = Hyrax::WorkRelation.new.find(work_id)
work_stats = rescue_and_retry("Retried WorkViewStat on #{user} for work #{work_id} too many times.") { WorkViewStat.statistics(work, start_date, user.id) }
stats = tally_results(work_stats, :work_views, stats) unless (work_stats.blank? || work_stats)
delay
end
end
require 'legato'
require 'hyrax/pageview'
require 'hyrax/download'
end
end

0 comments on commit dd2f780

Please sign in to comment.