mindmatch 0.0.3 → 0.0.4
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/mind_match/client.rb +46 -56
- data/lib/mind_match/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89cf943e81c64ca7244ebb19141d8585c46aaec4
|
4
|
+
data.tar.gz: 85e541059898e04083bd8d84f050647895bf0957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26fe24e59fa73d9faf474248d1be778b70b9b1b724ec02f680cea201d52698dfe71fa6aaaf8fb4b45b7429cedb5d7adb0b7500d168dfffd48e3dee28a6f1d1b8
|
7
|
+
data.tar.gz: 0d153f13a6c08daf7886051cad02956db8d94dc76d1172a48f09c9a2b5683ef95d3ea43d6d7a16a70d739a7854be916adfba0ff4311360771bc019e81ac8bac9
|
data/lib/mind_match/client.rb
CHANGED
@@ -38,8 +38,8 @@ module MindMatch
|
|
38
38
|
end
|
39
39
|
|
40
40
|
query_match_score = <<-GRAPHQL
|
41
|
-
query
|
42
|
-
|
41
|
+
query ($id: String!) {
|
42
|
+
getMatch(id: $id) {
|
43
43
|
id
|
44
44
|
status
|
45
45
|
data {
|
@@ -50,16 +50,16 @@ module MindMatch
|
|
50
50
|
GRAPHQL
|
51
51
|
|
52
52
|
raw_response = conn.get do |req|
|
53
|
-
req.body = JSON.generate(query: query_match_score)
|
53
|
+
req.body = JSON.generate(query: query_match_score, variables: {id: id}.to_json)
|
54
54
|
end
|
55
55
|
handle_error(raw_response)
|
56
56
|
response = JSON.parse(raw_response.body)
|
57
|
-
match = response.dig('data', '
|
57
|
+
match = response.dig('data', 'getMatch')
|
58
58
|
if match&.has_key?('data') # FIX: remove data namespace in mindmatch api
|
59
59
|
match = match.merge(match['data'] || query.to_h)
|
60
60
|
match.delete('data')
|
61
61
|
end
|
62
|
-
match
|
62
|
+
match || query.to_h
|
63
63
|
end
|
64
64
|
|
65
65
|
private
|
@@ -67,12 +67,12 @@ module MindMatch
|
|
67
67
|
|
68
68
|
def create_matches(talents:, companies:)
|
69
69
|
create_match_mutation = <<-GRAPHQL
|
70
|
-
mutation
|
71
|
-
|
70
|
+
mutation ($companies: [CompanyInput], $people: [PersonInput]) {
|
71
|
+
createMatch(
|
72
72
|
input: {
|
73
73
|
data: {
|
74
|
-
companies:
|
75
|
-
people:
|
74
|
+
companies: $companies,
|
75
|
+
people: $people
|
76
76
|
}
|
77
77
|
}
|
78
78
|
) {
|
@@ -82,67 +82,55 @@ module MindMatch
|
|
82
82
|
GRAPHQL
|
83
83
|
|
84
84
|
raw_response = conn.post do |req|
|
85
|
-
req.body = JSON.generate(
|
85
|
+
req.body = JSON.generate(
|
86
|
+
query: create_match_mutation,
|
87
|
+
variables: {
|
88
|
+
companies: companies.map(&method(:companiesql)),
|
89
|
+
people: talents.map(&method(:talentql))
|
90
|
+
}.to_json
|
91
|
+
)
|
86
92
|
end
|
87
93
|
handle_error(raw_response)
|
88
94
|
response = JSON.parse(raw_response.body)
|
89
|
-
match = response.dig('data', '
|
95
|
+
match = response.dig('data', 'createMatch')
|
90
96
|
if match&.has_key?('data') # FIX: remove data namespece in mindmatch api
|
91
97
|
match = match.merge(match['data'] || {'results'=>[], 'people'=>[], 'positions'=>[]})
|
92
98
|
match.delete('data')
|
93
99
|
end
|
94
|
-
match['id']
|
100
|
+
match && match['id']
|
95
101
|
end
|
96
102
|
|
97
103
|
def positionql(position)
|
98
104
|
position = stringify(position)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
EOS
|
105
|
+
{
|
106
|
+
refId: position['id'],
|
107
|
+
name: position['name'],
|
108
|
+
description: position['description'],
|
109
|
+
technologies: position['technologies'] || []
|
110
|
+
}
|
106
111
|
end
|
107
112
|
|
108
113
|
def companiesql(company)
|
109
114
|
company = stringify(company)
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
positions: [#{company['positions'].map(&method(:positionql)).join(', ')}]
|
118
|
-
}
|
119
|
-
EOS
|
120
|
-
else
|
121
|
-
warn "[DEPRECATION] providing postition without company information is deprecated."
|
122
|
-
<<-EOS.split.join(" ")
|
123
|
-
{
|
124
|
-
name: "company",
|
125
|
-
location: ["location"],
|
126
|
-
url: "http://example.com",
|
127
|
-
profileUrls: ["https://github.com/honeypotio", "https://linkedin.com/company/honeypot"],
|
128
|
-
positions: [#{positionql(company)}]
|
129
|
-
}
|
130
|
-
EOS
|
131
|
-
end
|
115
|
+
{
|
116
|
+
name: company['name'],
|
117
|
+
location: [company['location']].flatten,
|
118
|
+
url: company['url'],
|
119
|
+
profileUrls: company['profileUrls'] || [],
|
120
|
+
positions: company.fetch('positions', []).map(&method(:positionql))
|
121
|
+
}
|
132
122
|
end
|
133
123
|
|
134
124
|
def talentql(tal)
|
135
125
|
tal = stringify(tal)
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
}
|
145
|
-
EOS
|
126
|
+
{
|
127
|
+
refId: tal['id'],
|
128
|
+
name: tal['name'],
|
129
|
+
email: tal['email'],
|
130
|
+
profileUrls: tal['profileUrls'] || [],
|
131
|
+
resumeUrl: tal['resumeUrl'],
|
132
|
+
skills: tal['skills'] || []
|
133
|
+
}
|
146
134
|
end
|
147
135
|
|
148
136
|
def headers
|
@@ -154,7 +142,7 @@ module MindMatch
|
|
154
142
|
end
|
155
143
|
|
156
144
|
def handle_error(raw_response)
|
157
|
-
return if raw_response.status.to_s =~ /2\d\d/
|
145
|
+
return if raw_response.status.to_s =~ /2\d\d/ and error_free?(raw_response.body)
|
158
146
|
|
159
147
|
case raw_response.status
|
160
148
|
when 400 then raise(ArgumentError, raw_response.body)
|
@@ -164,12 +152,14 @@ module MindMatch
|
|
164
152
|
end
|
165
153
|
end
|
166
154
|
|
167
|
-
def
|
168
|
-
JSON.parse(
|
155
|
+
def error_free?(body)
|
156
|
+
!JSON.parse(body).has_key?('errors')
|
157
|
+
rescue StandardError
|
158
|
+
return false
|
169
159
|
end
|
170
160
|
|
171
|
-
def
|
172
|
-
|
161
|
+
def stringify(hash)
|
162
|
+
JSON.parse(JSON.generate(hash))
|
173
163
|
end
|
174
164
|
end
|
175
165
|
end
|
data/lib/mind_match/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mindmatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MindMatch
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-10-
|
13
|
+
date: 2017-10-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|