customer_miner 0.0.4 → 0.0.5

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: 0db83956f2fa755f345170f0def3c28e14b9cd61
4
- data.tar.gz: e3987c101c8b571c0515673f259ba18c649cd2de
3
+ metadata.gz: 81eb5c9e13684f39832f9211950eac5a3d2e1503
4
+ data.tar.gz: 833648c4adccd00a410df2fa397f0b0a8e70467f
5
5
  SHA512:
6
- metadata.gz: 0f7bd2fa3692862f8c3deb6dc390e50df14d55ddbad41857d605f5386cacc1c57ba1c66c793815cb0e9f4f2451d01da33a5b64a278e96060d651d9b978ff361a
7
- data.tar.gz: 874f1f122bc6c42ebfeb91005b999b4140034708af3780e34bdd825f05a056c8cb54b5e1d961f3c4eb086322f1fae74431b575b7c30584f39a5c74ed47bf8d51
6
+ metadata.gz: db3cdc7c3665a03b85469c01ac45b8daffc90fd0a2938ac98cc33be78ef0719515ec943f44a42de5458dd0e600c3de37398eb32a5a6beddd7adc38db8f85eb05
7
+ data.tar.gz: 741b683fb84fb2606e4b00b322e48f54bd377d57949fdbcc10e66af3a9b616e336a132e1861f938f624f6d7082b2330782a9e133d18ac86bbd18bceb2dfc6ce4
data/Gemfile CHANGED
@@ -1,9 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'clearbit'
4
- gem 'thread'
5
- gem 'concurrent-ruby',"~> 1.0.5"
6
-
7
3
  group :development, :test do
8
4
  gem 'pry'
9
5
  end
data/Gemfile.lock CHANGED
@@ -2,8 +2,9 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  customer_miner (0.0.4)
5
+ clearbit (~> 0.2)
6
+ concurrent-ruby (~> 1.0.5)
5
7
  thor (~> 0.19.4)
6
- typhoeus (~> 1.1)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
@@ -17,9 +18,6 @@ GEM
17
18
  crack (0.4.3)
18
19
  safe_yaml (~> 1.0.0)
19
20
  diff-lcs (1.3)
20
- ethon (0.10.1)
21
- ffi (>= 1.3.0)
22
- ffi (1.9.18)
23
21
  hashdiff (0.3.2)
24
22
  method_source (0.8.2)
25
23
  nestful (1.1.1)
@@ -44,9 +42,6 @@ GEM
44
42
  safe_yaml (1.0.4)
45
43
  slop (3.6.0)
46
44
  thor (0.19.4)
47
- thread (0.2.2)
48
- typhoeus (1.1.2)
49
- ethon (>= 0.9.0)
50
45
  webmock (2.3.2)
51
46
  addressable (>= 2.3.6)
52
47
  crack (>= 0.3.2)
@@ -56,12 +51,9 @@ PLATFORMS
56
51
  ruby
57
52
 
58
53
  DEPENDENCIES
59
- clearbit
60
- concurrent-ruby (~> 1.0.5)
61
54
  customer_miner!
62
55
  pry
63
56
  rspec
64
- thread
65
57
  webmock
66
58
 
67
59
  BUNDLED WITH
@@ -17,7 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.license = 'MIT'
18
18
 
19
19
  s.add_dependency('thor',["~> 0.19.4"])
20
- s.add_dependency('typhoeus',["~> 1.1"])
20
+ s.add_dependency('clearbit',["~> 0.2"])
21
+ s.add_dependency('concurrent-ruby',["~> 1.0.5"])
21
22
  s.add_development_dependency("rspec")
22
23
  s.add_development_dependency("webmock")
23
24
  end
@@ -1,7 +1,6 @@
1
1
  require 'csv'
2
2
  require 'json'
3
3
  require 'clearbit'
4
- require 'thread/pool'
5
4
  require 'concurrent'
6
5
 
7
6
  module CustomerMiner
@@ -30,7 +29,7 @@ module CustomerMiner
30
29
  domains = extract_domains
31
30
  puts "get #{domains.size} domain from csv #{@file}"
32
31
  puts "start request clearbit"
33
- res = query_clearbit(domains)
32
+ res = perform_query(domains)
34
33
  build_csv(res)
35
34
  end
36
35
 
@@ -42,25 +41,27 @@ module CustomerMiner
42
41
  rows.map { |row| row['Clearbit Company Domain'] }.compact.uniq
43
42
  end
44
43
 
45
- def query_clearbit(domains)
44
+ def perform_query(domains)
46
45
  Clearbit.key = @secret_key
47
- result = Concurrent::Array.new
48
- pool = Thread.pool(4)
49
- domains.each do |domain|
50
- pool.process do
51
- people = Clearbit::Prospector.search(domain: domain, roles: @roles)
52
- if people.size > 0
53
- result << { domain: domain, people: people }
54
- end
55
- puts "complete #{domain}"
56
- end
46
+ thread_pool = Concurrent::FixedThreadPool.new(5)
47
+ result_things = domains.map do |domain|
48
+ (Concurrent::Future.new executor: thread_pool do
49
+ fetch_people_data(domain)
50
+ end).execute
57
51
  end
58
52
 
59
- pool.shutdown
60
- puts "complete requests"
53
+ data = result_things.map(&:value)
54
+ result = result_things.map(&:value).compact
55
+ puts "complete requests #{result.size}"
61
56
  result
62
57
  end
63
58
 
59
+ def fetch_people_data(domain)
60
+ puts "start fetch #{domain}"
61
+ people = Clearbit::Prospector.search(domain: domain, roles: @roles)
62
+ { domain: domain, people: people }
63
+ end
64
+
64
65
  def build_csv(res)
65
66
  rows = res.map do |item|
66
67
  domain = item[:domain]
@@ -1,3 +1,3 @@
1
1
  module CustomerMiner
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: customer_miner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ocowchun
@@ -25,19 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.19.4
27
27
  - !ruby/object:Gem::Dependency
28
- name: typhoeus
28
+ name: clearbit
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.1'
33
+ version: '0.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.1'
40
+ version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: concurrent-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.5
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement