ae_easy-qa 0.0.32 → 0.0.34

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: 4950f51c210ef1ba1a6efca63cf44d13e422b7063e49be2fb4ddea58bef304a5
4
- data.tar.gz: 4204239f672a33aa1c280dd420824e033066abdc4897e3269037fb97701f5901
3
+ metadata.gz: 6d82799c2aade7ae53677871d20deb99b3bb3319ba380fcc88acaa4ac18bdb81
4
+ data.tar.gz: 6fb00dca45293956ff594875df6cba899dbde0b28e0065c4e3f8debbbe659497
5
5
  SHA512:
6
- metadata.gz: 93ecb76f504b23d8213a73d9cd0d1c1cb8a217c36423b6d375ddee202f6bbb42f11eb808cf27ecd4f00f270afed67ef7e69fdf85f40712064b0ae62b15c77b3c
7
- data.tar.gz: 42860dbd7c1406045eb6d64aefbfc21fdadb8ade8f7d09f574c0086d0607fc54cc0480303d5a4222aeb06d22ac582a89a863ad8ba83a771714b1e233f9036643
6
+ metadata.gz: d996f0fc651d37e19a9fa49ac199ac1cd37bbebf8a50b6d649bbbf167e10ab5fdbfdb6bafdda29901800367703309aec9117e373fd92b59e2690434e562aa92c
7
+ data.tar.gz: 8c44426a128b3e2c44596bf48ed6d10c2e17f701070fc2f153c1bf771b277f664416e908b465302574f572c1ddc6b2c04093238c65647c085cef5864f1200647
@@ -28,6 +28,7 @@ module AeEasy
28
28
 
29
29
  private
30
30
 
31
+ #thresholds are a setting where you can ignore errors if they are under a specific error rate
31
32
  def gather_threshold_totals
32
33
  rules.each{|field_to_validate, field_options|
33
34
  field_threshold = return_threshold(field_to_validate, field_options)
@@ -1,18 +1,19 @@
1
1
  module AeEasy
2
2
  module Qa
3
3
  class ValidateInternal
4
- attr_reader :scraper_name, :collections, :rules, :outputs
4
+ attr_reader :scraper_name, :collections, :rules, :outputs, :data
5
5
 
6
6
  def initialize(vars, config, outputs)
7
7
  @scraper_name = vars['scraper_name']
8
8
  @collections = vars['collections']
9
9
  @rules = config['individual_validations']
10
10
  @outputs = outputs
11
+ @data = vars['data']
11
12
  end
12
13
 
13
14
  def run
14
15
  begin
15
- ValidateScraper.new(scraper_name, collections, rules, outputs, thresholds).run
16
+ ValidateScraper.new(scraper_name, collections, rules, outputs, thresholds, data).run
16
17
  rescue StandardError => e
17
18
  puts "An error has occurred: #{e}"
18
19
  return nil
@@ -21,6 +22,7 @@ module AeEasy
21
22
 
22
23
  private
23
24
 
25
+ #thresholds are a setting where you can suppress errors if they are under a specific error rate
24
26
  def thresholds
25
27
  @thresholds ||= begin
26
28
  file_path = File.expand_path('thresholds.yaml', Dir.pwd)
@@ -34,14 +36,15 @@ module AeEasy
34
36
  end
35
37
 
36
38
  class ValidateScraper
37
- attr_reader :scraper_name, :collections, :rules, :outputs, :options
39
+ attr_reader :scraper_name, :collections, :rules, :outputs, :options, :data
38
40
 
39
- def initialize(scraper_name, collections, rules, outputs, thresholds)
41
+ def initialize(scraper_name, collections, rules, outputs, thresholds, data)
40
42
  @scraper_name = scraper_name
41
43
  @collections = collections
42
44
  @rules = rules
43
45
  @outputs = outputs
44
46
  @options = {}
47
+ @data = data
45
48
  options['thresholds'] = thresholds[scraper_name] if thresholds && thresholds[scraper_name]
46
49
  end
47
50
 
@@ -67,14 +70,14 @@ module AeEasy
67
70
  end
68
71
 
69
72
  def status_ok?
70
- !collection_response.parsed_response.nil? && collection_response.code == 200
73
+ !old_collection_response.parsed_response.nil? && old_collection_response.code == 200
71
74
  end
72
75
 
73
76
  def validate_collections
74
77
  collections.each do |collection_name|
75
78
  collection = collection_counts.find{|collection_hash| collection_hash['collection'] == collection_name }
76
79
  if collection
77
- ValidateCollection.new(scraper_name, collection_name, collection['outputs'], rules, outputs, options).run
80
+ ValidateCollection.new(scraper_name, collection_name, collection['outputs'], rules, outputs, options.merge({'data' => @data})).run
78
81
  else
79
82
  puts "collection #{collection_name} is missing"
80
83
  end
@@ -82,19 +85,29 @@ module AeEasy
82
85
  end
83
86
 
84
87
  def output_response
85
- if collection_response.parsed_response.nil?
88
+ if old_collection_response.parsed_response.nil?
86
89
  puts "collection response is null"
87
90
  else
88
- puts collection_response.parsed_response['message']
91
+ puts old_collection_response.parsed_response['message']
89
92
  end
90
93
  end
91
94
 
92
95
  def collection_counts
93
- @collection_counts ||= collection_response.parsed_response
96
+ @collection_counts ||= collection_response
94
97
  end
95
98
 
96
99
  def collection_response
97
- @collection_response || AnswersEngine::Client::ScraperJobOutput.new.collections(scraper_name)
100
+ json = JSON.parse(AnswersEngine::Client::ScraperJobOutput.new.collections(scraper_name).body)
101
+ if json['error'] == ""
102
+ @collection_response || json["data"]
103
+ else
104
+ puts "There was an error: #{JSON.pretty_generate(json['error'])}"
105
+ @collection_response
106
+ end
107
+ end
108
+
109
+ def old_collection_response
110
+ @old_collection_response || AnswersEngine::Client::ScraperJobOutput.new.collections(scraper_name)
98
111
  end
99
112
  end
100
113
 
@@ -107,6 +120,7 @@ module AeEasy
107
120
  @total_records = total_records
108
121
  @rules = rules
109
122
  @outputs = outputs
123
+ @data = options['data']
110
124
  @options = options
111
125
  @errors = { errored_items: [] }
112
126
  end
@@ -147,6 +161,7 @@ module AeEasy
147
161
  data = []
148
162
  page = 1
149
163
  while data.count < total_records
164
+ # if there is an issue maybe due to this method response due to new stream data response AnswersEngine::Client::JobOutput.new(per_page:500, page: page).all
150
165
  records = AnswersEngine::Client::JobOutput.new(per_page:500, page: page).all(most_recent_finished_job['id'], collection_name).parsed_response
151
166
  sleep 1
152
167
  if records
@@ -1,5 +1,5 @@
1
1
  module AeEasy
2
2
  module Qa
3
- VERSION = "0.0.32"
3
+ VERSION = "0.0.34"
4
4
  end
5
5
  end
data/lib/ae_easy/qa.rb CHANGED
@@ -22,10 +22,12 @@ module AeEasy
22
22
  @data = data
23
23
  end
24
24
 
25
+ #this method is for validating "internal" scrapers that run on AnswersEngine
25
26
  def validate_internal(vars, outputs)
26
27
  ValidateInternal.new(vars, config, outputs).run
27
28
  end
28
29
 
30
+ #this method is for validating data from "external" sources
29
31
  def validate_external(outputs, collection_name)
30
32
  ValidateExternal.new(data, config, outputs, collection_name, options).run
31
33
  end
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.32
4
+ version: 0.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lynam
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-03 00:00:00.000000000 Z
11
+ date: 2024-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: answersengine
@@ -92,7 +92,7 @@ licenses:
92
92
  metadata:
93
93
  homepage_uri: https://answersengine.com
94
94
  source_code_uri: https://github.com/answersengine/ae_easy-qa
95
- post_install_message:
95
+ post_install_message:
96
96
  rdoc_options: []
97
97
  require_paths:
98
98
  - lib
@@ -107,9 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubyforge_project:
111
- rubygems_version: 2.7.8
112
- signing_key:
110
+ rubygems_version: 3.2.15
111
+ signing_key:
113
112
  specification_version: 4
114
113
  summary: AnswersEngine Easy Quality Assurance gem
115
114
  test_files: []