darlingtonia 2.1.0 → 2.2.0
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/darlingtonia/hyrax_record_importer.rb +21 -7
- data/lib/darlingtonia/importer.rb +2 -0
- data/lib/darlingtonia/record_importer.rb +7 -1
- data/lib/darlingtonia/validator.rb +25 -2
- data/lib/darlingtonia/version.rb +1 -1
- data/spec/darlingtonia/importer_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7c349e432568a10f8f77a939d0464e511466f0bc7ae30f7d7f5ff134a1bb656
|
4
|
+
data.tar.gz: 5a89d7d2e778e35ab4213af0648c5c99857f264851f50a40dfbfa76f1440a79a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ef901a03b12a77bf06ffb61622d4ff606c3369d872c1bc72f8bf8975c96faa9450b1826cda254c915afef0a03ebd1908db00e818ddc6d1087a1aeb83a823c9f
|
7
|
+
data.tar.gz: ac6bd1de71971065ec2432c27ad786e810f306f54271fd1d800117706479745b93b98b2e3115be806227becd01aaecbb570ae0a366370d231bc6d9a2b3ec6222
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
2.2.0 - Tue Feb 12, 2019
|
2
|
+
|
3
|
+
* Improved default logging
|
4
|
+
* logs are more easily parsed, e.g., by splunk
|
5
|
+
* logs contain summary information
|
6
|
+
* option to pass in a batch_id to track successes and failures per batch
|
7
|
+
|
1
8
|
2.1.0 - Tue Feb 12, 2019
|
2
9
|
|
3
10
|
* Map a variety of values for 'visibility' to their Hyrax approved equivalents
|
@@ -13,6 +13,18 @@ module Darlingtonia
|
|
13
13
|
# @return [String] The fedora ID for a Collection.
|
14
14
|
attr_accessor :collection_id
|
15
15
|
|
16
|
+
# @!attribute [rw] batch_id
|
17
|
+
# @return [String] an id number associated with the process that kicked off this import run
|
18
|
+
attr_accessor :batch_id
|
19
|
+
|
20
|
+
# @!attribute [rw] success_count
|
21
|
+
# @return [String] the number of records this importer has successfully created
|
22
|
+
attr_accessor :success_count
|
23
|
+
|
24
|
+
# @!attribute [rw] failure_count
|
25
|
+
# @return [String] the number of records this importer has failed to create
|
26
|
+
attr_accessor :failure_count
|
27
|
+
|
16
28
|
# @param attributes [Hash] Attributes that come
|
17
29
|
# from the UI or importer rather than from
|
18
30
|
# the CSV/mapper.
|
@@ -23,8 +35,10 @@ module Darlingtonia
|
|
23
35
|
info_stream: Darlingtonia.config.default_info_stream,
|
24
36
|
attributes: {})
|
25
37
|
self.collection_id = attributes[:collection_id]
|
38
|
+
self.batch_id = attributes[:batch_id]
|
26
39
|
set_depositor(attributes[:depositor_id])
|
27
|
-
|
40
|
+
@success_count = 0
|
41
|
+
@failure_count = 0
|
28
42
|
super(error_stream: error_stream, info_stream: info_stream)
|
29
43
|
end
|
30
44
|
|
@@ -137,8 +151,8 @@ module Darlingtonia
|
|
137
151
|
# Create an object using the Hyrax actor stack
|
138
152
|
# We assume the object was created as expected if the actor stack returns true.
|
139
153
|
def create_for(record:)
|
140
|
-
info_stream <<
|
141
|
-
|
154
|
+
info_stream << "event: record_import_started, batch_id: #{batch_id}, collection_id: #{collection_id}, record_title: #{record.respond_to?(:title) ? record.title : record}"
|
155
|
+
|
142
156
|
additional_attrs = {
|
143
157
|
uploaded_files: create_upload_files(record),
|
144
158
|
depositor: @depositor.user_key
|
@@ -156,14 +170,14 @@ module Darlingtonia
|
|
156
170
|
attrs)
|
157
171
|
|
158
172
|
if Hyrax::CurationConcern.actor.create(actor_env)
|
159
|
-
info_stream << "
|
173
|
+
info_stream << "event: record_created, batch_id: #{batch_id}, record_id: #{created.id}, collection_id: #{collection_id}, record_title: #{attrs[:title].first}"
|
174
|
+
@success_count += 1
|
160
175
|
else
|
161
176
|
created.errors.each do |attr, msg|
|
162
|
-
error_stream << "
|
177
|
+
error_stream << "event: validation_failed, batch_id: #{batch_id}, collection_id: #{collection_id}, attribute: #{attr.capitalize}, message: #{msg}, record_title: #{attrs[:title].first}"
|
163
178
|
end
|
179
|
+
@failure_count += 1
|
164
180
|
end
|
165
|
-
|
166
|
-
info_stream << "Record created at: #{created.id}"
|
167
181
|
end
|
168
182
|
end
|
169
183
|
end
|
@@ -34,6 +34,7 @@ module Darlingtonia
|
|
34
34
|
def initialize(parser:, record_importer: RecordImporter.new)
|
35
35
|
self.parser = parser
|
36
36
|
self.record_importer = record_importer
|
37
|
+
@info_stream = Darlingtonia.config.default_info_stream
|
37
38
|
end
|
38
39
|
|
39
40
|
##
|
@@ -42,6 +43,7 @@ module Darlingtonia
|
|
42
43
|
# @return [void]
|
43
44
|
def import
|
44
45
|
records.each { |record| record_importer.import(record: record) }
|
46
|
+
@info_stream << "event: finish_import, batch_id: #{record_importer.batch_id}, successful_record_count: #{record_importer.success_count}, failed_record_count: #{record_importer.failure_count}"
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -7,7 +7,13 @@ module Darlingtonia
|
|
7
7
|
# @return [#<<]
|
8
8
|
# @!attribute [rw] info_stream
|
9
9
|
# @return [#<<]
|
10
|
-
|
10
|
+
# @!attribute [rw] batch_id
|
11
|
+
# @return [String] an optional batch id for this import run
|
12
|
+
# @!attribute [rw] success_count
|
13
|
+
# @return [Integer] a count of the records that were successfully created
|
14
|
+
# @!attribute [rw] failure_count
|
15
|
+
# @return [Integer] a count of the records that failed import
|
16
|
+
attr_accessor :error_stream, :info_stream, :batch_id, :success_count, :failure_count
|
11
17
|
|
12
18
|
##
|
13
19
|
# @param error_stream [#<<]
|
@@ -53,7 +53,28 @@ module Darlingtonia
|
|
53
53
|
#
|
54
54
|
# @see Parser#validate
|
55
55
|
class Validator
|
56
|
+
##
|
57
|
+
# A representation of an error encountered in validation.
|
56
58
|
Error = Struct.new(:validator, :name, :description, :lineno) do
|
59
|
+
##
|
60
|
+
# @!attribute [rw] validator
|
61
|
+
# @return [#to_s] the validator that generated this error
|
62
|
+
# @!attribute [rw] name
|
63
|
+
# @return [#to_s] a short descriptive name for the given error
|
64
|
+
# @!attribute [rw] description
|
65
|
+
# @return [#to_s] a long form description or message
|
66
|
+
# @!attribute [rw] lineno
|
67
|
+
# @return [#to_s] the line number, or other indication of the location
|
68
|
+
# where the error was encountered
|
69
|
+
|
70
|
+
##
|
71
|
+
# @return [Boolean]
|
72
|
+
def validator_error?
|
73
|
+
true
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# @return [String]
|
57
78
|
def to_s
|
58
79
|
"#{name}: #{description} (#{validator})"
|
59
80
|
end
|
@@ -79,16 +100,18 @@ module Darlingtonia
|
|
79
100
|
errors.map { |error| error_stream << error }
|
80
101
|
end
|
81
102
|
end
|
82
|
-
# rubocop:enable Lint/UnusedMethodArgument
|
83
103
|
|
84
104
|
private
|
85
105
|
|
106
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
107
|
+
|
86
108
|
##
|
87
109
|
# @return [Enumerator<Error>]
|
88
110
|
#
|
89
|
-
# rubocop:disable Lint/UnusedMethodArgument
|
90
111
|
def run_validation(parser:)
|
91
112
|
[].to_enum
|
92
113
|
end
|
114
|
+
|
115
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
93
116
|
end
|
94
117
|
end
|
data/lib/darlingtonia/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darlingtonia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Data Curation Experts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active-fedora
|