ae_easy-qa 0.0.20 → 0.0.21
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/lib/ae_easy/qa.rb +3 -2
- data/lib/ae_easy/qa/save_output.rb +52 -11
- data/lib/ae_easy/qa/validate_external.rb +4 -3
- data/lib/ae_easy/qa/validate_internal.rb +1 -1
- data/lib/ae_easy/qa/version.rb +1 -1
- 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: b37b9eefd295fd1816c02b906a56eeb0ed2d0a8108c3e93992e4953f36786387
|
4
|
+
data.tar.gz: f8e58457cf18340e6879d088e94031cdc869c05866324474a68465b9aa9318f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2ed8e4b43bef024e4543255123a3df6423ffd6a3c3a72d4bb0b440bcc6eb92c86591ddcf9dbccf0ebcc53b42756c0cf6b191ac4ffa9c2f130a3964d47dbda4d
|
7
|
+
data.tar.gz: 284d9e40adb10130d153a6758714af314e228352e805d6882dbf5acb695cd59ea41692db999305d3c294b93ee3e39f41832b63a9f2c7a05ee1567fb83747d398
|
data/lib/ae_easy/qa.rb
CHANGED
@@ -14,10 +14,11 @@ module AeEasy
|
|
14
14
|
module Qa
|
15
15
|
class Validator
|
16
16
|
attr_accessor :config
|
17
|
-
attr_reader :data, :errors
|
17
|
+
attr_reader :data, :options, :errors
|
18
18
|
|
19
19
|
def initialize(data=nil, options={})
|
20
20
|
load_config
|
21
|
+
@options = options
|
21
22
|
@data = data
|
22
23
|
end
|
23
24
|
|
@@ -26,7 +27,7 @@ module AeEasy
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def validate_external(outputs, collection_name)
|
29
|
-
ValidateExternal.new(data, config, outputs, collection_name).run
|
30
|
+
ValidateExternal.new(data, config, outputs, collection_name, options).run
|
30
31
|
end
|
31
32
|
|
32
33
|
private
|
@@ -2,17 +2,20 @@ module AeEasy
|
|
2
2
|
module Qa
|
3
3
|
class SaveOutput
|
4
4
|
attr_reader :total_items, :rules, :errors, :collection_name,
|
5
|
-
:outputs, :summary, :error_totals, :fields_to_ignore
|
5
|
+
:outputs, :summary, :error_totals, :fields_to_ignore,
|
6
|
+
:specific_validations_to_ignore, :options
|
6
7
|
|
7
|
-
def initialize(total_items, rules, errors, collection_name, outputs)
|
8
|
+
def initialize(total_items, rules, errors, collection_name, outputs, options)
|
8
9
|
@total_items = total_items
|
9
10
|
@rules = rules
|
10
11
|
@errors = errors
|
11
12
|
@collection_name = collection_name
|
12
13
|
@outputs = outputs
|
14
|
+
@options = options
|
13
15
|
@summary = Hash.new(0)
|
14
16
|
@error_totals = {}
|
15
17
|
@fields_to_ignore = []
|
18
|
+
@specific_validations_to_ignore = []
|
16
19
|
end
|
17
20
|
|
18
21
|
def run
|
@@ -26,29 +29,66 @@ module AeEasy
|
|
26
29
|
private
|
27
30
|
|
28
31
|
def gather_threshold_totals
|
29
|
-
rules.each{|field_to_validate,
|
30
|
-
|
32
|
+
rules.each{|field_to_validate, field_options|
|
33
|
+
field_threshold = return_threshold(field_to_validate, field_options)
|
34
|
+
if field_threshold
|
31
35
|
error_total = errors[:errored_items].inject(0){|total, errored_item|
|
32
36
|
failed_fields = errored_item[:failures].keys.collect{|failure_key|
|
33
37
|
extract_field(failure_key)
|
34
38
|
}.uniq
|
35
|
-
total
|
39
|
+
total += 1 if failed_fields.include?(field_to_validate)
|
40
|
+
total
|
36
41
|
}
|
37
42
|
error_totals[field_to_validate] = error_total
|
43
|
+
else
|
44
|
+
field_options.each do |validation|
|
45
|
+
potential_failure_name = "#{field_to_validate}_#{validation[0]}_fail"
|
46
|
+
if options['thresholds'][potential_failure_name]
|
47
|
+
error_total = errors[:errored_items].inject(0){|total, errored_item|
|
48
|
+
failed_validations = errored_item[:failures].keys.collect{|failure_key|
|
49
|
+
"#{failure_key}_fail"
|
50
|
+
}
|
51
|
+
total += 1 if failed_validations.include?(potential_failure_name)
|
52
|
+
total
|
53
|
+
}
|
54
|
+
error_totals[potential_failure_name] = error_total
|
55
|
+
end
|
56
|
+
end
|
38
57
|
end
|
39
58
|
}
|
40
59
|
end
|
41
60
|
|
42
61
|
def gather_fields_to_ignore
|
43
|
-
rules.each{|field_to_validate,
|
44
|
-
|
62
|
+
rules.each{|field_to_validate, field_options|
|
63
|
+
field_threshold = return_threshold(field_to_validate, field_options)
|
64
|
+
if field_threshold
|
45
65
|
total_errors = error_totals[field_to_validate]
|
46
|
-
|
47
|
-
|
66
|
+
if total_errors
|
67
|
+
success_ratio = (total_items - total_errors).to_f / total_items
|
68
|
+
fields_to_ignore.push(field_to_validate) if success_ratio > field_threshold
|
69
|
+
end
|
70
|
+
else
|
71
|
+
field_options.each do |validation|
|
72
|
+
potential_failure_name = "#{field_to_validate}_#{validation[0]}_fail"
|
73
|
+
total_errors = error_totals[potential_failure_name]
|
74
|
+
if total_errors
|
75
|
+
specific_validation_threshold = options['thresholds'][potential_failure_name].to_f
|
76
|
+
success_ratio = (total_items - total_errors).to_f / total_items
|
77
|
+
specific_validations_to_ignore.push(potential_failure_name) if success_ratio > specific_validation_threshold
|
78
|
+
end
|
79
|
+
end
|
48
80
|
end
|
49
81
|
}
|
50
82
|
end
|
51
83
|
|
84
|
+
def return_threshold(field_to_validate, field_options)
|
85
|
+
if options['thresholds']
|
86
|
+
options['thresholds'][field_to_validate]
|
87
|
+
else
|
88
|
+
field_options['threshold'] || options['threshold']
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
52
92
|
def save_group_errors
|
53
93
|
errors.each{|error_name, output_hash|
|
54
94
|
if error_name != :errored_items
|
@@ -60,7 +100,7 @@ module AeEasy
|
|
60
100
|
|
61
101
|
def save_errors
|
62
102
|
errors[:errored_items].each do |errored_item|
|
63
|
-
remove_threshold_failures(errored_item) if fields_to_ignore.any?
|
103
|
+
remove_threshold_failures(errored_item) if fields_to_ignore.any? || specific_validations_to_ignore.any?
|
64
104
|
errored_item[:failures].each do |error_key, value|
|
65
105
|
key = "#{error_key.to_s}_#{value.to_s}"
|
66
106
|
summary[key] += 1
|
@@ -72,8 +112,9 @@ module AeEasy
|
|
72
112
|
|
73
113
|
def remove_threshold_failures(errored_item)
|
74
114
|
errored_item[:failures].delete_if{|error_name, fail|
|
115
|
+
specific_validation_name = "#{error_name}_fail"
|
75
116
|
field_name = extract_field(error_name)
|
76
|
-
fields_to_ignore.include?(field_name)
|
117
|
+
fields_to_ignore.include?(field_name) || specific_validations_to_ignore.include?(specific_validation_name)
|
77
118
|
}
|
78
119
|
end
|
79
120
|
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module AeEasy
|
2
2
|
module Qa
|
3
3
|
class ValidateExternal
|
4
|
-
attr_reader :data, :errors, :rules, :outputs, :collection_name
|
4
|
+
attr_reader :data, :errors, :rules, :outputs, :collection_name, :options
|
5
5
|
|
6
|
-
def initialize(data, config, outputs, collection_name)
|
6
|
+
def initialize(data, config, outputs, collection_name, options)
|
7
7
|
@data = data
|
8
8
|
@rules = config['individual_validations'] if config
|
9
9
|
@outputs = outputs
|
10
10
|
@collection_name = collection_name
|
11
|
+
@options = options
|
11
12
|
@errors = { errored_items: [] }
|
12
13
|
end
|
13
14
|
|
@@ -17,7 +18,7 @@ module AeEasy
|
|
17
18
|
ValidateGroups.new(data, nil, collection_name, errors).run
|
18
19
|
ValidateRules.new(data, errors, rules).run if rules
|
19
20
|
end
|
20
|
-
SaveOutput.new(data.count, rules, errors, collection_name, outputs).run
|
21
|
+
SaveOutput.new(data.count, rules, errors, collection_name, outputs, options).run
|
21
22
|
return errors
|
22
23
|
rescue StandardError => e
|
23
24
|
puts "An error has occurred: #{e}"
|
@@ -88,7 +88,7 @@ module AeEasy
|
|
88
88
|
ValidateGroups.new(data, scraper_name, collection_name, errors).run
|
89
89
|
ValidateRules.new(data, errors, rules).run if rules
|
90
90
|
end
|
91
|
-
SaveOutput.new(data.count, rules, errors, outputs_collection_name, outputs).run
|
91
|
+
SaveOutput.new(data.count, rules, errors, outputs_collection_name, outputs, {}).run
|
92
92
|
end
|
93
93
|
|
94
94
|
private
|
data/lib/ae_easy/qa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ae_easy-qa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Lynam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: answersengine
|