diff --git a/Gemfile b/Gemfile index d7eb6df4e..431df5c01 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,7 @@ gem 'blacklight_range_limit', '~> 8.5' gem 'bolognese', '>= 1.9.10' gem 'bootstrap', '~> 4.6' gem 'bootstrap-datepicker-rails' -gem 'bulkrax', github: 'samvera-labs/bulkrax', branch: 'main' +gem 'bulkrax', github: 'samvera-labs/bulkrax', branch: 'guided-import-metrics' gem 'byebug', group: %i[development test] gem 'capybara', group: %i[test] gem 'capybara-screenshot', '~> 1.0', group: %i[test] diff --git a/Gemfile.lock b/Gemfile.lock index 2bf5b814e..be7ddf3bc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,8 +10,8 @@ GIT GIT remote: https://github.com/samvera-labs/bulkrax.git - revision: 370cf9cd324b11a8afcdd10912db2baf59456928 - branch: main + revision: de1c3fd043c660317532a68f2dc98ae49548ee43 + branch: guided-import-metrics specs: bulkrax (9.3.5) bagit (~> 0.6.0) diff --git a/app/models/ability.rb b/app/models/ability.rb index 7ce629f48..d346f6644 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -118,6 +118,10 @@ def can_export_works? can_create_any_work? end + def can_read_bulkrax_metrics? + admin? || superadmin? + end + ## # @api public # diff --git a/app/models/concerns/account_settings.rb b/app/models/concerns/account_settings.rb index e9a2b6f62..799e7f4a7 100644 --- a/app/models/concerns/account_settings.rb +++ b/app/models/concerns/account_settings.rb @@ -276,6 +276,7 @@ def reload_library_config def configure_bulkrax Bulkrax.config do |config| config.guided_import_enabled = guided_import_enabled? + config.guided_import_metrics_enabled = guided_import_metrics_enabled? end end @@ -290,6 +291,16 @@ def guided_import_enabled? false end + def guided_import_metrics_enabled? + return false unless guided_import_enabled? + + ActiveRecord::Base.connection.transaction(requires_new: true) do + Flipflop.include_guided_import_metrics? + end + rescue ActiveRecord::StatementInvalid + false + end + def configure_hyrax Hyrax.config do |config| # A short-circuit of showing download links diff --git a/config/features.rb b/config/features.rb index b678b167b..c709b649c 100644 --- a/config/features.rb +++ b/config/features.rb @@ -54,5 +54,9 @@ feature :include_guided_import, default: false, description: "Enable the guided import workflow." + + feature :include_guided_import_metrics, + default: false, + description: "Enable product metrics for the guided import workflow." end end diff --git a/db/schema.rb b/db/schema.rb index 6ebee3b4e..87c3c4310 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2026_02_02_120000) do +ActiveRecord::Schema[7.2].define(version: 2026_04_03_000000) do # These are extensions that must be enabled in order to support this database enable_extension "hstore" enable_extension "pgcrypto" @@ -116,6 +116,23 @@ t.index ["user_id"], name: "index_bulkrax_exporters_on_user_id" end + create_table "bulkrax_import_metrics", force: :cascade do |t| + t.string "metric_type", null: false + t.string "event", null: false + t.bigint "importer_id" + t.bigint "user_id" + t.string "session_id" + t.jsonb "payload", default: {} + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.index ["created_at"], name: "index_bulkrax_import_metrics_on_created_at" + t.index ["event"], name: "index_bulkrax_import_metrics_on_event" + t.index ["importer_id"], name: "index_bulkrax_import_metrics_on_importer_id" + t.index ["metric_type", "created_at"], name: "index_bulkrax_import_metrics_on_metric_type_and_created_at" + t.index ["metric_type"], name: "index_bulkrax_import_metrics_on_metric_type" + t.index ["user_id"], name: "index_bulkrax_import_metrics_on_user_id" + end + create_table "bulkrax_importer_runs", force: :cascade do |t| t.bigint "importer_id" t.integer "total_work_entries", default: 0 @@ -1054,6 +1071,7 @@ add_foreign_key "accounts", "endpoints", column: "redis_endpoint_id", on_delete: :nullify add_foreign_key "accounts", "endpoints", column: "solr_endpoint_id", on_delete: :nullify add_foreign_key "bulkrax_exporter_runs", "bulkrax_exporters", column: "exporter_id" + add_foreign_key "bulkrax_import_metrics", "bulkrax_importers", column: "importer_id" add_foreign_key "bulkrax_importer_runs", "bulkrax_importers", column: "importer_id" add_foreign_key "bulkrax_pending_relationships", "bulkrax_importer_runs", column: "importer_run_id" add_foreign_key "collection_type_participants", "hyrax_collection_types"