Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bulkrax and add user stat importer decorator #2428

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ GIT

GIT
remote: https://github.com/samvera/bulkrax.git
revision: a751f48d45478c67bff4e4cb07ca1b3d01d6131a
revision: 0e8de6174cd305bfdccdfbb8dd090c7c446f763d
branch: main
specs:
bulkrax (9.0.2)
Expand Down
24 changes: 24 additions & 0 deletions app/services/hyrax/user_stat_importer_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

# OVERRIDE Hyrax v5.0.1 to use Hyrax.query_service to find the fileset instead of FileSet.find
# Remove this if https://github.com/samvera/hyrax/pull/6992 gets merged and Hyrax is updated appropriately

module Hyrax
module UserStatImporterDecorator
private

def process_files(stats, user, start_date)
file_ids_for_user(user).each do |file_id|
file = Hyrax.query_service.find_by(id: file_id)
view_stats = extract_stats_for(object: file, from: FileViewStat, start_date: start_date, user: user)
stats = tally_results(view_stats, :views, stats) if view_stats.present?
delay
dl_stats = extract_stats_for(object: file, from: FileDownloadStat, start_date: start_date, user: user)
stats = tally_results(dl_stats, :downloads, stats) if dl_stats.present?
delay
end
end
end
end

Hyrax::UserStatImporter.prepend(Hyrax::UserStatImporterDecorator)
Loading