diff --git a/.rubocop.yml b/.rubocop.yml index 62131010d..400847823 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -13,6 +13,7 @@ AllCops: - 'app/services/report.rb' - 'app/services/work_loader.rb' - 'app/services/hyrax/actor_factory.rb' + - 'app/services/hyrax/user_stat_importer.rb' - 'spec/services/hyrax/actor_factory_spec.rb' - 'db/**/*' - 'lib/tasks/batch.rake' diff --git a/app/services/hyrax/user_stat_importer.rb b/app/services/hyrax/user_stat_importer.rb new file mode 100644 index 000000000..919d41461 --- /dev/null +++ b/app/services/hyrax/user_stat_importer.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true +require Hyrax::Engine.root.join('app/services/hyrax/user_stat_importer.rb') +module Hyrax + class UserStatImporter + require 'legato' + require 'hyrax/pageview' + require 'hyrax/download' + end +end diff --git a/lib/tasks/stats_tasks.rake b/lib/tasks/stats_tasks.rake new file mode 100644 index 000000000..ff19331f9 --- /dev/null +++ b/lib/tasks/stats_tasks.rake @@ -0,0 +1,10 @@ +# frozen_string_literal: true +namespace :hyrax do + namespace :stats do + desc "Cache work view, file view & file download stats for all users" + task user_stats: :environment do + importer = Hyrax::UserStatImporter.new(verbose: true, logging: true, delay_secs: 1) + importer.import + end + end +end