bulkrax 3.0.0.beta7 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33cb77498f84a977101dd70e7de2ae3853a47c9c9fb514a156df759ab35f6b75
4
- data.tar.gz: 49f433acd439eb004c8d95c668811df214fcd1bef5fdbfb1477cbc6cd6d598b7
3
+ metadata.gz: 7810d87388103e4ff6d160e6acb64a492dcfcf16a23f93ad6848f6cc97f2d9db
4
+ data.tar.gz: 75bee56959564774f20cda642b6c732cd9cb8a4fbd19222222fbac429effc949
5
5
  SHA512:
6
- metadata.gz: 58f561feac1a1d3c85f442c2612ed7e52105fb335358dda3eeb07a51433c5edc03d2f4c26402384be1529002e00d5acd46f5d5e51c715d20d27e21bc7198e68d
7
- data.tar.gz: 35b539c937e0d66427a0d5f8bf801431b33aaa1d26dfef83786a97f3704a9aafbce4dd33903b7b9f6b1026a8d4339d2b6033b80b1e7aa725bc07d7e463b5493d
6
+ metadata.gz: 74297cb60a695e46fa97389b6a9a23124c816304d636267e72585a286f370c923aefe0e10727d3a215fc8d7a1eefa579cb84cd3b84b8e8f65a72619c0c10176e
7
+ data.tar.gz: 57e62164db12eb01bbfa200d612ecd0439099e257d760009b289644e93fd043e7edc3f95c08f023fed2746abfc2c57fac996b542abc0cf724794dc78bc422ddc
@@ -82,18 +82,18 @@ module Bulkrax
82
82
  # Work-Collection membership is added to the child as member_of_collection_ids
83
83
  # This is adding the reverse relationship, from the child to the parent
84
84
  def collection_parent_work_child
85
- child_records[:works].each do |child_record|
86
- ::Hyrax::Collections::NestedCollectionPersistenceService.persist_nested_collection_for(parent: parent_record, child: child_record)
87
- # TODO: add counters for :processed_parents and :failed_parents
88
- Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
89
- end
85
+ child_work_ids = child_records[:works].map(&:id)
86
+ parent_record.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
87
+
88
+ parent_record.add_member_objects(child_work_ids)
89
+ ImporterRun.find(importer_run_id).increment!(:processed_relationships, child_work_ids.count) # rubocop:disable Rails/SkipsModelValidations
90
90
  end
91
91
 
92
92
  # Collection-Collection membership is added to the as member_ids
93
93
  def collection_parent_collection_child
94
94
  child_records[:collections].each do |child_record|
95
95
  ::Hyrax::Collections::NestedCollectionPersistenceService.persist_nested_collection_for(parent: parent_record, child: child_record)
96
- Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
96
+ ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
97
97
  end
98
98
  end
99
99
 
@@ -103,14 +103,12 @@ module Bulkrax
103
103
  child_records[:works].each_with_index do |child_record, i|
104
104
  records_hash[i] = { id: child_record.id }
105
105
  end
106
- attrs = {
107
- work_members_attributes: records_hash
108
- }
109
- parent_record.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if parent_record.respond_to?(:reindex_extent)
106
+ attrs = { work_members_attributes: records_hash }
107
+ parent_record.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX)
110
108
  env = Hyrax::Actors::Environment.new(parent_record, Ability.new(user), attrs)
109
+
111
110
  Hyrax::CurationConcern.actor.update(env)
112
- # TODO: add counters for :processed_parents and :failed_parents
113
- Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
111
+ ImporterRun.find(importer_run_id).increment!(:processed_relationships, child_records[:works].count) # rubocop:disable Rails/SkipsModelValidations
114
112
  end
115
113
 
116
114
  def reschedule(parent_identifier:, importer_run_id:)
@@ -27,6 +27,7 @@ module Bulkrax
27
27
  end
28
28
  exporter_run = ExporterRun.find(args[1])
29
29
  return entry if exporter_run.enqueued_records.positive?
30
+
30
31
  if exporter_run.failed_records.positive?
31
32
  exporter_run.exporter.status_info('Complete (with failures)')
32
33
  else
@@ -96,7 +96,8 @@ module Bulkrax
96
96
  end
97
97
 
98
98
  def current_run
99
- @current_run ||= self.exporter_runs.create!(total_work_entries: self.limit || parser.total)
99
+ total = self.limit || parser.total
100
+ @current_run ||= self.exporter_runs.create!(total_work_entries: total, enqueued_records: total)
100
101
  end
101
102
 
102
103
  def last_run
@@ -142,7 +142,7 @@ module Bulkrax
142
142
 
143
143
  def import_objects(types_array = nil)
144
144
  self.only_updates ||= false
145
- types = types_array || %w[work collection file_set relationship]
145
+ types = types_array || %w[collection work file_set relationship]
146
146
  if parser.class == Bulkrax::CsvParser
147
147
  parser.create_objects(types)
148
148
  else
@@ -21,6 +21,8 @@ module Bulkrax
21
21
  status_info(e)
22
22
  else
23
23
  status_info
24
+ ensure
25
+ self.save!
24
26
  end
25
27
  return @item
26
28
  end
@@ -23,20 +23,28 @@ module Bulkrax
23
23
  @collections = []
24
24
  @works = []
25
25
  @file_sets = []
26
- records.map do |r|
27
- model_field_mappings.each do |model_mapping|
28
- if r[model_mapping.to_sym]&.downcase == 'collection'
29
- @collections << r
30
- elsif r[model_mapping.to_sym]&.downcase == 'fileset'
31
- @file_sets << r
32
- else
33
- @works << r
26
+
27
+ if model_field_mappings.map { |mfm| mfm.to_sym.in?(records.first.keys) }.any?
28
+ records.map do |r|
29
+ model_field_mappings.map(&:to_sym).each do |model_mapping|
30
+ next unless r.key?(model_mapping)
31
+
32
+ if r[model_mapping].casecmp('collection').zero?
33
+ @collections << r
34
+ elsif r[model_mapping].casecmp('fileset').zero?
35
+ @file_sets << r
36
+ else
37
+ @works << r
38
+ end
34
39
  end
35
40
  end
41
+ @collections = @collections.flatten.compact.uniq
42
+ @file_sets = @file_sets.flatten.compact.uniq
43
+ @works = @works.flatten.compact.uniq
44
+ else # if no model is specified, assume all records are works
45
+ @works = records.flatten.compact.uniq
36
46
  end
37
- @collections = @collections.flatten.compact.uniq
38
- @file_sets = @file_sets.flatten.compact.uniq
39
- @works = @works.flatten.compact.uniq
47
+
40
48
  true
41
49
  end
42
50
 
@@ -110,7 +118,7 @@ module Bulkrax
110
118
 
111
119
  def create_objects(types_array = nil)
112
120
  index = 0
113
- (types_array || %w[work collection file_set relationship]).each do |type|
121
+ (types_array || %w[collection work file_set relationship]).each do |type|
114
122
  if type.eql?('relationship')
115
123
  ScheduleRelationshipsJob.set(wait: 5.minutes).perform_later(importer_id: importerexporter.id)
116
124
  next
@@ -262,7 +270,7 @@ module Bulkrax
262
270
  # Changed to grep as wc -l counts blank lines, and ignores the final unescaped line (which may or may not contain data)
263
271
  def total
264
272
  @total = importer.parser_fields['total'] || 0 if importer?
265
- @total = importerexporter.entries.count if exporter?
273
+ @total = limit || current_record_ids.count if exporter?
266
274
 
267
275
  return @total || 0
268
276
  rescue StandardError
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bulkrax
4
- VERSION = '3.0.0.beta7'
4
+ VERSION = '3.0.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulkrax
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta7
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Kaufman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-06 00:00:00.000000000 Z
11
+ date: 2022-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -393,9 +393,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
393
393
  version: '0'
394
394
  required_rubygems_version: !ruby/object:Gem::Requirement
395
395
  requirements:
396
- - - ">"
396
+ - - ">="
397
397
  - !ruby/object:Gem::Version
398
- version: 1.3.1
398
+ version: '0'
399
399
  requirements: []
400
400
  rubygems_version: 3.1.4
401
401
  signing_key: