g5-jobbing 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7882ff36d5f80f6cb2bd0ed703d3b22e0f693886
4
- data.tar.gz: 6768f527fcfb3faaa7f288a7bbc35009a12e97d7
3
+ metadata.gz: a2147f115caef3edd60bf72bc57d7c799819d184
4
+ data.tar.gz: 4d1cabffe26b770e7b00eac55d70d3afdbf2a43e
5
5
  SHA512:
6
- metadata.gz: 796cd60f7ccd8d5850a398f8f4883a9d9dfc2681973c9959852f7ff5dcb2a06f7019dc0d3ca3a658d7f89c9a9183c27dd047b7b3058545fb8d7416a8f13cf0f9
7
- data.tar.gz: 205a41aa4e599599d81ba5e845f1607e648d27d02e7e486cbcb3a387384ad81e15aa092039052622d73f8437711796172e3972f61ebb46634c03981ae44b9ccc
6
+ metadata.gz: 562f2b7f8b2d08ab7bea20e2acd29f713581a9dd3f93a621ecad95557328d97a44e3641785bb1409b302170cdadee17b08cf1369bbf5422834f89a9d8c67e7c2
7
+ data.tar.gz: a46a41b8c1a46914927c8ef118922c74086fc888f5a9f74accd3b604ae2a08112ca987747ec9d1fe61d98c0b9e837a55fc18aea201de90840624bc2be2f6f240
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+
16
+ g5-jobbing-*.gem
@@ -0,0 +1,16 @@
1
+ module G5::Jobbing::JobFetcher
2
+ include G5::Jobbing::AccessToken
3
+
4
+ def fetch_get(url)
5
+ response = HTTParty.get(url,
6
+ {query: {access_token: get_access_token},
7
+ headers: {'Content-Type' => 'application/json', 'Accept' => 'application/json'}}
8
+ )
9
+ job_hashes = JSON.parse(response.body)['jobs']
10
+ job_hashes.collect { |job_hash| G5::Jobbing::Job.new(job_hash) }
11
+ end
12
+
13
+ def jobs_base_url
14
+ "#{ENV['JOBS_URL']}/api/v1/jobs"
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  class G5::Jobbing::JobRetriever
2
- include G5::Jobbing::AccessToken
2
+ include G5::Jobbing::JobFetcher
3
3
  attr_accessor :location_setting_urns
4
4
 
5
5
  def initialize(params={})
@@ -7,15 +7,11 @@ class G5::Jobbing::JobRetriever
7
7
  end
8
8
 
9
9
  def perform
10
- response = HTTParty.get(jobs_url_for_locations,
11
- {query: {access_token: get_access_token},
12
- headers: {'Content-Type' => 'application/json', 'Accept' => 'application/json'}}
13
- )
14
- JSON.parse(response.body)['jobs'].collect { |job_hash| G5::Jobbing::Job.new(job_hash) }
10
+ fetch_get jobs_url_for_locations
15
11
  end
16
12
 
17
13
  def jobs_url_for_locations
18
- "#{ENV['JOBS_URL']}/api/v1/jobs?current=true&integration_setting_urn=#{CGI.escape(locations_as_parameter)}"
14
+ "#{jobs_base_url}?current=true&integration_setting_urn=#{locations_as_parameter}"
19
15
  end
20
16
 
21
17
  def locations_as_parameter
@@ -0,0 +1,14 @@
1
+ class G5::Jobbing::JobStat
2
+ include Virtus.model
3
+
4
+ attribute :rolled_up_by, String
5
+ attribute :jobs, Array
6
+
7
+ def error_count
8
+ self.jobs.count { |job| job.error_state }
9
+ end
10
+
11
+ def error_messages
12
+ self.jobs.collect { |job| job.message }.compact
13
+ end
14
+ end
@@ -0,0 +1,36 @@
1
+ class G5::Jobbing::JobStatRetriever
2
+ include G5::Jobbing::JobFetcher
3
+
4
+ attr_accessor :rollup_by
5
+
6
+ def initialize(params={})
7
+ self.rollup_by = params[:rollup_by]
8
+ @job_stats = Hash.new
9
+ end
10
+
11
+ def perform
12
+ response = fetch_get "#{jobs_base_url}?current=true"
13
+ roll_it_up response
14
+ end
15
+
16
+ private
17
+ def roll_it_up(jobs)
18
+ jobs.each do |job|
19
+ job_stat = find_matching_job_stat(job)
20
+ job_stat.jobs << job if job_stat
21
+ end
22
+ @job_stats
23
+ end
24
+
25
+ def find_matching_job_stat(job)
26
+ parent = self.rollup_by.detect { |key_values| key_values.last.include?(job.urn) }.try(:first)
27
+ return unless parent
28
+
29
+ job_stat_key = @job_stats.keys.detect { |js_key| parent == js_key }
30
+ return @job_stats[job_stat_key] if job_stat_key
31
+
32
+ job_stat = G5::Jobbing::JobStat.new(rolled_up_by: parent, jobs: [])
33
+ @job_stats[parent] = job_stat
34
+ job_stat
35
+ end
36
+ end
@@ -1,5 +1,5 @@
1
1
  module G5
2
2
  module Jobbing
3
- VERSION = "0.0.2"
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
data/lib/g5/jobbing.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'active_support/core_ext/object/try'
1
2
  require 'active_support/core_ext/object/blank'
2
3
  require 'g5/jobbing/version'
3
4
  require 'g5_authentication_client'
@@ -11,6 +12,9 @@ module G5
11
12
  end
12
13
 
13
14
  require 'g5/jobbing/access_token'
15
+ require 'g5/jobbing/job_fetcher'
14
16
  require 'g5/jobbing/job'
17
+ require 'g5/jobbing/job_stat'
15
18
  require 'g5/jobbing/job_retriever'
16
19
  require 'g5/jobbing/job_starter'
20
+ require 'g5/jobbing/job_stat_retriever'
@@ -0,0 +1,100 @@
1
+ {
2
+ "jobs": [
3
+ {
4
+ "uid": "https://g5-jobs-staging.herokuapp.com/api/v1/jobs/g5-job-1t1slmdz",
5
+ "urn": "g5-job-1t1slmdz",
6
+ "state": "inventory_etl_transform_failure",
7
+ "created_at": "2014-11-14T11:32:40.385-08:00",
8
+ "updated_at": "2014-11-14T11:32:44.968-08:00",
9
+ "integration_setting_uid": "http://hub.g5dxm.com/clients/g5-c-1soj8z7v-g5-selfstorage/locations/g5-cl-i27shqbr-value-self-storage-sitelink-unit-categorization/locations_integration_settings/g5-lis-1t0thzui",
10
+ "integration_setting_urn": "g5-lis-1t0thzui",
11
+ "message": "undefined method `*' for nil:NilClass\n/app/app/services/site_link/transformation/compute_in_store_rate_and_web_rate.rb:29:in `in_store_rate_from_web_rate'\n/app/app/services/site_link/transformation/compute_in_store_rate_and_web_rate.rb:13:in `block in \u003cclass:ComputeInStoreRateAndWebRate\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:15:in `block in reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `each'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer_log_decorator.rb:21:in `reduce'\n/app/app/services/site_link/transformation/transform_storage_unit.rb:10:in `block in \u003cclass:TransformStorageUnit\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/app/services/site_link/transformation/transform_storage_units.rb:18:in `block (2 levels) in \u003cclass:TransformStorageUnits\u003e'\n/app/app/services/site_link/transformation/transform_storage_units.rb:17:in `map'\n/app/app/services/site_link/transformation/transform_storage_units.rb:17:in `block in \u003cclass:TransformStorageUnits\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:15:in `block in reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `each'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer_log_decorator.rb:21:in `reduce'\n/app/app/services/site_link/transform.rb:9:in `block in \u003cclass:Transform\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/app/etl_strategies/site_link_etl_strategy.rb:10:in `transform'\n/app/app/etl_strategies/base_etl_strategy.rb:12:in `block in execute'\n/app/app/etl_strategies/base_etl_strategy.rb:25:in `safe'\n/app/app/etl_strategies/base_etl_strategy.rb:12:in `execute'\n/app/app/workers/etl_worker.rb:9:in `perform'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:75:in `execute_job'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:122:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:122:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/active_record.rb:6:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/logging.rb:22:in `with_context'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/logging.rb:7:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:127:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:127:in `invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:51:in `block in process'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:98:in `stats'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:50:in `process'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:122:in `dispatch'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'",
12
+ "error_state": true,
13
+ "success_state": false
14
+ },
15
+ {
16
+ "uid": "https://g5-jobs-staging.herokuapp.com/api/v1/jobs/g5-job-1t1slkm2",
17
+ "urn": "g5-job-1t1slkm2",
18
+ "state": "completed_with_no_errors",
19
+ "created_at": "2014-11-14T11:32:17.740-08:00",
20
+ "updated_at": "2014-11-14T11:32:28.662-08:00",
21
+ "integration_setting_uid": "http://hub.g5dxm.com/clients/g5-c-1soj8z7v-g5-selfstorage/locations/g5-cl-i27sjquw-value-ss-venice-sitelink-unit-categorization/locations_integration_settings/g5-lis-1t0thj3p",
22
+ "integration_setting_urn": "g5-lis-1t0thj3p",
23
+ "message": null,
24
+ "error_state": false,
25
+ "success_state": true
26
+ },
27
+ {
28
+ "uid": "https://g5-jobs-staging.herokuapp.com/api/v1/jobs/g5-job-1t1slj81",
29
+ "urn": "g5-job-1t1slj81",
30
+ "state": "completed_with_no_errors",
31
+ "created_at": "2014-11-14T11:31:59.764-08:00",
32
+ "updated_at": "2014-11-14T11:32:08.946-08:00",
33
+ "integration_setting_uid": "http://hub.g5dxm.com/clients/g5-c-1soj8z7v-g5-selfstorage/locations/g5-cl-1soj8z8d-501-storage/locations_integration_settings/g5-lis-3",
34
+ "integration_setting_urn": "g5-lis-3",
35
+ "message": null,
36
+ "error_state": false,
37
+ "success_state": true
38
+ },
39
+ {
40
+ "uid": "https://g5-jobs-staging.herokuapp.com/api/v1/jobs/g5-job-1t1sldig",
41
+ "urn": "g5-job-1t1sldig",
42
+ "state": "inventory_etl_transform_failure",
43
+ "created_at": "2014-11-14T11:30:45.447-08:00",
44
+ "updated_at": "2014-11-14T11:30:50.067-08:00",
45
+ "integration_setting_uid": "http://hub.g5dxm.com/clients/g5-c-1soj8z7v-g5-selfstorage/locations/g5-cl-1sontt19-541-storage/locations_integration_settings/g5-lis-9",
46
+ "integration_setting_urn": "g5-lis-9",
47
+ "message": "undefined method `*' for nil:NilClass\n/app/app/services/site_link/transformation/compute_in_store_rate_and_web_rate.rb:29:in `in_store_rate_from_web_rate'\n/app/app/services/site_link/transformation/compute_in_store_rate_and_web_rate.rb:13:in `block in \u003cclass:ComputeInStoreRateAndWebRate\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:15:in `block in reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `each'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer_log_decorator.rb:21:in `reduce'\n/app/app/services/site_link/transformation/transform_storage_unit.rb:10:in `block in \u003cclass:TransformStorageUnit\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/app/services/site_link/transformation/transform_storage_units.rb:18:in `block (2 levels) in \u003cclass:TransformStorageUnits\u003e'\n/app/app/services/site_link/transformation/transform_storage_units.rb:17:in `map'\n/app/app/services/site_link/transformation/transform_storage_units.rb:17:in `block in \u003cclass:TransformStorageUnits\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:15:in `block in reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `each'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer_log_decorator.rb:21:in `reduce'\n/app/app/services/site_link/transform.rb:9:in `block in \u003cclass:Transform\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/app/etl_strategies/site_link_etl_strategy.rb:10:in `transform'\n/app/app/etl_strategies/base_etl_strategy.rb:12:in `block in execute'\n/app/app/etl_strategies/base_etl_strategy.rb:25:in `safe'\n/app/app/etl_strategies/base_etl_strategy.rb:12:in `execute'\n/app/app/workers/etl_worker.rb:9:in `perform'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:75:in `execute_job'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:122:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:122:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/active_record.rb:6:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/logging.rb:22:in `with_context'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/logging.rb:7:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:127:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:127:in `invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:51:in `block in process'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:98:in `stats'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:50:in `process'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:122:in `dispatch'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'",
48
+ "error_state": true,
49
+ "success_state": false
50
+ },
51
+ {
52
+ "uid": "https://g5-jobs-staging.herokuapp.com/api/v1/jobs/g5-job-1t1sl9t3",
53
+ "urn": "g5-job-1t1sl9t3",
54
+ "state": "inventory_etl_transform_failure",
55
+ "created_at": "2014-11-14T11:29:57.957-08:00",
56
+ "updated_at": "2014-11-14T11:30:02.971-08:00",
57
+ "integration_setting_uid": "http://hub.g5dxm.com/clients/g5-c-1soj8z7v-g5-selfstorage/locations/g5-cl-i27smlhd-sitelink-test-system/locations_integration_settings/g5-lis-1t0s4n2j",
58
+ "integration_setting_urn": "g5-lis-1t0s4n2j",
59
+ "message": "undefined method `*' for nil:NilClass\n/app/app/services/site_link/transformation/compute_in_store_rate_and_web_rate.rb:29:in `in_store_rate_from_web_rate'\n/app/app/services/site_link/transformation/compute_in_store_rate_and_web_rate.rb:13:in `block in \u003cclass:ComputeInStoreRateAndWebRate\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:15:in `block in reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `each'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer_log_decorator.rb:21:in `reduce'\n/app/app/services/site_link/transformation/transform_storage_unit.rb:10:in `block in \u003cclass:TransformStorageUnit\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/app/services/site_link/transformation/transform_storage_units.rb:18:in `block (2 levels) in \u003cclass:TransformStorageUnits\u003e'\n/app/app/services/site_link/transformation/transform_storage_units.rb:17:in `map'\n/app/app/services/site_link/transformation/transform_storage_units.rb:17:in `block in \u003cclass:TransformStorageUnits\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:15:in `block in reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `each'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer.rb:14:in `reduce'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/organizer/with_reducer_log_decorator.rb:21:in `reduce'\n/app/app/services/site_link/transform.rb:9:in `block in \u003cclass:Transform\u003e'\n/app/vendor/bundle/ruby/2.1.0/gems/light-service-0.4.0/lib/light-service/action.rb:38:in `block in executed'\n/app/app/etl_strategies/site_link_etl_strategy.rb:10:in `transform'\n/app/app/etl_strategies/base_etl_strategy.rb:12:in `block in execute'\n/app/app/etl_strategies/base_etl_strategy.rb:25:in `safe'\n/app/app/etl_strategies/base_etl_strategy.rb:12:in `execute'\n/app/app/workers/etl_worker.rb:9:in `perform'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:75:in `execute_job'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:122:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:122:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/active_record.rb:6:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/logging.rb:22:in `with_context'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/server/logging.rb:7:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:127:in `call'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/middleware/chain.rb:127:in `invoke'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:51:in `block in process'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:98:in `stats'\n/app/vendor/bundle/ruby/2.1.0/gems/sidekiq-3.2.6/lib/sidekiq/processor.rb:50:in `process'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:122:in `dispatch'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'\n/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'",
60
+ "error_state": true,
61
+ "success_state": false
62
+ },
63
+ {
64
+ "uid": "https://g5-jobs-staging.herokuapp.com/api/v1/jobs/g5-job-1t1skxui",
65
+ "urn": "g5-job-1t1skxui",
66
+ "state": "completed_with_no_errors",
67
+ "created_at": "2014-11-14T11:27:22.466-08:00",
68
+ "updated_at": "2014-11-14T11:27:36.617-08:00",
69
+ "integration_setting_uid": "http://hub.g5dxm.com/clients/g5-c-1soj8z7v-g5-selfstorage/locations/g5-cl-i23xpxk1-pitfields-east-india-trading-company/locations_integration_settings/g5-lis-1t0tf3u0",
70
+ "integration_setting_urn": "g5-lis-1t0tf3u0",
71
+ "message": null,
72
+ "error_state": false,
73
+ "success_state": true
74
+ },
75
+ {
76
+ "uid": "https://g5-jobs-staging.herokuapp.com/api/v1/jobs/g5-job-1t1schlp",
77
+ "urn": "g5-job-1t1schlp",
78
+ "state": "inventory_etl_load_failure",
79
+ "created_at": "2014-11-14T10:21:39.057-08:00",
80
+ "updated_at": "2014-11-14T10:21:47.331-08:00",
81
+ "integration_setting_uid": "http://hub.g5dxm.com/clients/g5-c-1skmeepf-clowns-monkeys-jokers/locations/g5-cl-1ssino43-test-rent-cafe/locations_integration_settings/g5-lis-1",
82
+ "integration_setting_urn": "g5-lis-1",
83
+ "message": "inventory-service responded with 422: {\"external_id\":[\"has already been taken\"]}\ninventory-service responded with 422: {\"external_id\":[\"has already been taken\"]}",
84
+ "error_state": true,
85
+ "success_state": false
86
+ },
87
+ {
88
+ "uid": "https://g5-jobs-staging.herokuapp.com/api/v1/jobs/g5-job-1t1onnnk",
89
+ "urn": "g5-job-1t1onnnk",
90
+ "state": "completed_with_no_errors",
91
+ "created_at": "2014-11-13T17:08:45.297-08:00",
92
+ "updated_at": "2014-11-13T17:08:53.007-08:00",
93
+ "integration_setting_uid": "http://hub.g5dxm.com/clients/g5-c-1skmeepf-clowns-monkeys-jokers/locations/g5-cl-1skmeept-blahblahblah/locations_integration_settings/g5-lis-1t0n85r2",
94
+ "integration_setting_urn": "g5-lis-1t0n85r2",
95
+ "message": null,
96
+ "error_state": false,
97
+ "success_state": true
98
+ }
99
+ ]
100
+ }
@@ -8,7 +8,6 @@ describe G5::Jobbing::JobRetriever do
8
8
 
9
9
  describe :perform do
10
10
  let(:body) { fixture('jobs.json') }
11
- let(:body_hash) { JSON.parse(body)[:jobs] }
12
11
  let(:token) { 'the toke' }
13
12
  before do
14
13
  expect(G5AuthenticationClient::Client).to receive(:new).and_return(double(:token, get_access_token: token))
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe G5::Jobbing::JobStatRetriever do
4
+ describe 'perform' do
5
+ let(:body) { fixture('all-jobs.json') }
6
+ let(:body_hash) { JSON.parse(body)['jobs'] }
7
+ let(:foo_error_messages) { [body_hash.detect { |hash| hash['urn'] == 'g5-job-1t1slmdz' }['message']] }
8
+ let(:bar_error_messages) { [body_hash.detect { |hash| hash['urn'] == 'g5-job-1t1schlp' }['message']] }
9
+ let(:token) { 'the toke' }
10
+ let(:job_stat_retriever) { G5::Jobbing::JobStatRetriever.new(rollup_by: roll_up_by) }
11
+
12
+ before do
13
+ expect(G5AuthenticationClient::Client).to receive(:new).and_return(double(:token, get_access_token: token))
14
+ expect(HTTParty).to receive(:get).with("#{job_stat_retriever.jobs_base_url}?current=true",
15
+ {query: {access_token: token},
16
+ headers: {'Content-Type' => 'application/json', 'Accept' => 'application/json'}}).
17
+ and_return(double(:response, body: body))
18
+ end
19
+ let(:roll_up_by) { {foo: ['g5-job-1t1slmdz', 'g5-job-1t1slkm2'], no_matches: ['madeup'], bar: ['g5-job-1t1schlp', 'g5-job-1t1onnnk', 'g5-job-1t1skxui']} }
20
+
21
+ subject { job_stat_retriever.perform }
22
+
23
+ its(:keys) { is_expected.to eq([:foo, :bar]) }
24
+
25
+ it 'rolls up foo' do
26
+ expect(subject[:foo].jobs.count).to eq(2)
27
+ expect(subject[:foo].error_count).to eq(1)
28
+ expect(subject[:foo].error_messages).to eq(foo_error_messages)
29
+ end
30
+
31
+ it 'rolls up bar' do
32
+ expect(subject[:bar].jobs.count).to eq(3)
33
+ expect(subject[:bar].error_count).to eq(1)
34
+ expect(subject[:bar].error_messages).to eq(bar_error_messages)
35
+ end
36
+
37
+ it 'has no no_matches' do
38
+ expect(subject[:no_matches]).to be_nil
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe G5::Jobbing::JobStat do
4
+ let(:rolled_up_by) { 'rolled up by' }
5
+ let(:jobs) { [G5::Jobbing::Job.new(error_state: true, message: 'you dun screwed up son'),
6
+ G5::Jobbing::Job.new(error_state: false),
7
+ G5::Jobbing::Job.new(error_state: true, message: 'boom'),] }
8
+
9
+ subject { G5::Jobbing::JobStat.new(rolled_up_by: rolled_up_by, jobs: jobs) }
10
+
11
+ its(:rolled_up_by) { is_expected.to eq(rolled_up_by) }
12
+ its(:jobs) { is_expected.to eq(jobs) }
13
+ its(:error_count) { is_expected.to eq(2) }
14
+ its(:error_messages) { is_expected.to eq(['you dun screwed up son', 'boom']) }
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: g5-jobbing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Perry Hertler
@@ -154,13 +154,19 @@ files:
154
154
  - lib/g5/jobbing.rb
155
155
  - lib/g5/jobbing/access_token.rb
156
156
  - lib/g5/jobbing/job.rb
157
+ - lib/g5/jobbing/job_fetcher.rb
157
158
  - lib/g5/jobbing/job_retriever.rb
158
159
  - lib/g5/jobbing/job_starter.rb
160
+ - lib/g5/jobbing/job_stat.rb
161
+ - lib/g5/jobbing/job_stat_retriever.rb
159
162
  - lib/g5/jobbing/version.rb
163
+ - spec/fixtures/all-jobs.json
160
164
  - spec/fixtures/jobs.json
161
165
  - spec/lib/g5/jobbing/job_retriever_spec.rb
162
166
  - spec/lib/g5/jobbing/job_spec.rb
163
167
  - spec/lib/g5/jobbing/job_starter_spec.rb
168
+ - spec/lib/g5/jobbing/job_stat_retriever_spec.rb
169
+ - spec/lib/g5/jobbing/job_stat_spec.rb
164
170
  - spec/spec_helper.rb
165
171
  homepage: ''
166
172
  licenses:
@@ -187,8 +193,11 @@ signing_key:
187
193
  specification_version: 4
188
194
  summary: Uses the g5-jobs service to manage and organize jobs.
189
195
  test_files:
196
+ - spec/fixtures/all-jobs.json
190
197
  - spec/fixtures/jobs.json
191
198
  - spec/lib/g5/jobbing/job_retriever_spec.rb
192
199
  - spec/lib/g5/jobbing/job_spec.rb
193
200
  - spec/lib/g5/jobbing/job_starter_spec.rb
201
+ - spec/lib/g5/jobbing/job_stat_retriever_spec.rb
202
+ - spec/lib/g5/jobbing/job_stat_spec.rb
194
203
  - spec/spec_helper.rb