apihub-leadscore 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/leadscore.gemspec +1 -0
- data/lib/apihub-leadscore.rb +1 -0
- data/lib/apihub/lead_score.rb +11 -76
- data/lib/apihub/lead_score/async.rb +36 -0
- data/lib/apihub/lead_score/score.rb +81 -0
- data/lib/apihub/lead_score/version.rb +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72f43639af5ff0bca53eaaae40fd60af2af8f58e
|
4
|
+
data.tar.gz: dd33419091800cf77e0734d37e4887cb65e8215b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0253edcf52c607238dfdf84eeefdb5a5f7ce84177d4d703e2524623010db7af651153e6a6f252c79b6e18a738b39410b443c535a4d5eada2bb1b95a62161bb2
|
7
|
+
data.tar.gz: 9a0bdb704f541483b8f6bf13fc5fa04a135fbe110bea04f4c639a0867044ff7c9d4d223caefbcb6107bdde7648cf6784e7637b6ace13a31ca0520da407489951
|
data/README.md
CHANGED
data/leadscore.gemspec
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require 'apihub/lead_score'
|
data/lib/apihub/lead_score.rb
CHANGED
@@ -1,26 +1,14 @@
|
|
1
1
|
require "apihub"
|
2
2
|
require "apihub/lead_score/version"
|
3
|
+
|
4
|
+
require "apihub/lead_score/async"
|
3
5
|
require "apihub/lead_score/email_providers"
|
6
|
+
require "apihub/lead_score/score"
|
4
7
|
|
5
8
|
module APIHub
|
6
9
|
module LeadScore extend self
|
7
10
|
include APIHub
|
8
11
|
|
9
|
-
attr_accessor :defaults
|
10
|
-
|
11
|
-
self.defaults = Mash.new({
|
12
|
-
twitter_followers_weight: 0.05,
|
13
|
-
angellist_followers_weight: 0.05,
|
14
|
-
klout_score_weight: 0.05,
|
15
|
-
company_twitter_followers_weight: 0.05,
|
16
|
-
company_alexa_rank_weight: 0.000005,
|
17
|
-
company_google_rank_weight: 0.05,
|
18
|
-
company_employees_weight: 0.5,
|
19
|
-
company_raised_weight: 0.0000005,
|
20
|
-
company_score: 10,
|
21
|
-
total_score: 1415
|
22
|
-
})
|
23
|
-
|
24
12
|
def api_key=(value)
|
25
13
|
APIHub.api_key = value
|
26
14
|
end
|
@@ -46,69 +34,16 @@ module APIHub
|
|
46
34
|
|
47
35
|
return unless person || company
|
48
36
|
|
49
|
-
result = Mash.new(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
def score(result, options = {})
|
56
|
-
options = defaults.merge(options)
|
57
|
-
|
58
|
-
score = 0.0
|
59
|
-
|
60
|
-
return score unless result
|
61
|
-
|
62
|
-
if result.avatar
|
63
|
-
score += 5
|
64
|
-
end
|
65
|
-
|
66
|
-
if result.twitter
|
67
|
-
score += result.twitter.followers * options.twitter_followers_weight
|
68
|
-
end
|
69
|
-
|
70
|
-
if result.angellist
|
71
|
-
score += result.angellist.followers * options.angellist_followers_weight
|
72
|
-
end
|
73
|
-
|
74
|
-
if result.klout && result.klout.score
|
75
|
-
score += result.klout.score * options.klout_score_weight
|
76
|
-
end
|
77
|
-
|
78
|
-
if company = result.company
|
79
|
-
unless company.personal
|
80
|
-
score += options.company_score
|
81
|
-
end
|
82
|
-
|
83
|
-
if company.raised
|
84
|
-
score += company.raised *
|
85
|
-
options.company_raised_weight
|
86
|
-
end
|
37
|
+
result = Mash.new(
|
38
|
+
person: person,
|
39
|
+
company: company
|
40
|
+
)
|
87
41
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
42
|
+
result.merge!(
|
43
|
+
score: Score.calculate(result)
|
44
|
+
)
|
92
45
|
|
93
|
-
|
94
|
-
score += 1 / (company.alexa.globalRank *
|
95
|
-
options.company_alexa_rank_weight)
|
96
|
-
end
|
97
|
-
|
98
|
-
if company.google && company.google.rank && company.google.rank > 0
|
99
|
-
score += 1 / (company.google.rank *
|
100
|
-
options.company_google_rank_weight)
|
101
|
-
end
|
102
|
-
|
103
|
-
if company.twitter
|
104
|
-
score += company.twitter.followers *
|
105
|
-
options.company_twitter_followers_weight
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
score /= options.total_score
|
110
|
-
|
111
|
-
[score.round(1), 1.0].min
|
46
|
+
result
|
112
47
|
end
|
113
48
|
end
|
114
49
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'thread/pool'
|
2
|
+
|
3
|
+
module APIHub
|
4
|
+
module LeadScore
|
5
|
+
class Async
|
6
|
+
def self.instance
|
7
|
+
@instance ||= self.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.lookup(email, &block)
|
11
|
+
instance.lookup(email, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.finish
|
15
|
+
instance.finish
|
16
|
+
@instance = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :pool
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
@pool = options[:pool] || Thread.pool(8)
|
23
|
+
end
|
24
|
+
|
25
|
+
def lookup(email, &block)
|
26
|
+
pool.process do
|
27
|
+
block.call LeadScore.lookup(email)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def finish
|
32
|
+
pool.shutdown
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module APIHub
|
2
|
+
module LeadScore
|
3
|
+
module Score extend self
|
4
|
+
attr_accessor :defaults
|
5
|
+
|
6
|
+
self.defaults = Mash.new({
|
7
|
+
twitter_followers_weight: 0.05,
|
8
|
+
angellist_followers_weight: 0.05,
|
9
|
+
klout_score_weight: 0.05,
|
10
|
+
company_twitter_followers_weight: 0.05,
|
11
|
+
company_alexa_rank_weight: 0.000005,
|
12
|
+
company_google_rank_weight: 0.05,
|
13
|
+
company_employees_weight: 0.5,
|
14
|
+
company_raised_weight: 0.0000005,
|
15
|
+
company_score: 10,
|
16
|
+
total_score: 1415
|
17
|
+
})
|
18
|
+
|
19
|
+
def calculate(result, options = {})
|
20
|
+
options = defaults.merge(options)
|
21
|
+
|
22
|
+
score = 0.0
|
23
|
+
|
24
|
+
return score unless result
|
25
|
+
|
26
|
+
if person = result.person
|
27
|
+
if person.avatar
|
28
|
+
score += 5
|
29
|
+
end
|
30
|
+
|
31
|
+
if person.twitter.followers
|
32
|
+
score += person.twitter.followers * options.twitter_followers_weight
|
33
|
+
end
|
34
|
+
|
35
|
+
if person.angellist.followers
|
36
|
+
score += person.angellist.followers * options.angellist_followers_weight
|
37
|
+
end
|
38
|
+
|
39
|
+
if person.klout.score
|
40
|
+
score += person.klout.score * options.klout_score_weight
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if company = result.company
|
45
|
+
unless company.personal
|
46
|
+
score += options.company_score
|
47
|
+
end
|
48
|
+
|
49
|
+
if company.raised
|
50
|
+
score += company.raised *
|
51
|
+
options.company_raised_weight
|
52
|
+
end
|
53
|
+
|
54
|
+
if company.employees
|
55
|
+
score += company.employees *
|
56
|
+
options.company_employees_weight
|
57
|
+
end
|
58
|
+
|
59
|
+
if company.alexa.globalRank
|
60
|
+
score += 1 / (company.alexa.globalRank *
|
61
|
+
options.company_alexa_rank_weight)
|
62
|
+
end
|
63
|
+
|
64
|
+
if company.google.rank && company.google.rank > 0
|
65
|
+
score += 1 / (company.google.rank *
|
66
|
+
options.company_google_rank_weight)
|
67
|
+
end
|
68
|
+
|
69
|
+
if company.twitter.followers
|
70
|
+
score += company.twitter.followers *
|
71
|
+
options.company_twitter_followers_weight
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
score /= options.total_score
|
76
|
+
|
77
|
+
[score.round(1), 1.0].min
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apihub-leadscore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex MacCaw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thread
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description:
|
70
84
|
email:
|
71
85
|
- alex@apihub.co
|
@@ -81,8 +95,11 @@ files:
|
|
81
95
|
- Rakefile
|
82
96
|
- bin/apihub-leadscore
|
83
97
|
- leadscore.gemspec
|
98
|
+
- lib/apihub-leadscore.rb
|
84
99
|
- lib/apihub/lead_score.rb
|
100
|
+
- lib/apihub/lead_score/async.rb
|
85
101
|
- lib/apihub/lead_score/email_providers.rb
|
102
|
+
- lib/apihub/lead_score/score.rb
|
86
103
|
- lib/apihub/lead_score/version.rb
|
87
104
|
homepage: https://apihub.co
|
88
105
|
licenses:
|