peoplegroup-connectors 0.1.29 → 0.1.34

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
  SHA256:
3
- metadata.gz: 1a80093436809a688b3886c6257cce5fc56a9d66195f79697c7e7cc391fe95a0
4
- data.tar.gz: 53ab138d9dd878b733ba1e33a15d4bf5e0b494a364a524d148c689e5b2112af7
3
+ metadata.gz: 7b10c3d12519bd5dd49e0a002677ed9c5972c9b5d13a378421043c1140977411
4
+ data.tar.gz: 14b399de4dba169b28feaf7f2a64f7a71eea215c690549c903337876d29c7c4f
5
5
  SHA512:
6
- metadata.gz: e1bce5ccb1041c7fea8e99a5bb6fd485fadc237cf4d8a5c7d56d2f8ed4dbf24701dc099142e74714076f9ff31141207b2fb02880cf02b1b9a740a783fd5d1076
7
- data.tar.gz: 3d9362da12e2246cced5a36b4c0019e4a2f54bf3f896b8908480a7afde4209e308ca94e9a328a981dade11f059aec46667c187eb1baaeddf37bb8682e7596596
6
+ metadata.gz: a7896627f7124a8fd6dcee9722e061e4dfc555445f2f6764b847ea81b155aa837c4024f4720c25f6d293fd253526dc9244574b4226b371fce001034fbc2b2e5d
7
+ data.tar.gz: 6b07b93367fdf2a1841e171ba09d4f993bcb665e0b6362426d13fcb6fbcf1025061feb6a258adcf927103c96d95f1c2c1f8489856f206438d6bb38076d77d0ae
@@ -0,0 +1,4 @@
1
+ - slack_email: cristiano
2
+ bamboo_email: ccasella
3
+ - slack_email: kencjohnston
4
+ bamboo_email: kjohnston
@@ -7,7 +7,8 @@ module PeopleGroup
7
7
  class Bamboo
8
8
  MAX_RETRIES = 3
9
9
 
10
- def initialize
10
+ def initialize(use_report: false)
11
+ @use_report = use_report
11
12
  @client = Bamboozled.client(subdomain: 'gitlab', api_key: ENV['BAMBOO_API_KEY'])
12
13
  end
13
14
 
@@ -39,6 +40,15 @@ module PeopleGroup
39
40
  end
40
41
  alias_method :search_team_member_by_field, :search_employee_by_field
41
42
 
43
+ def slack_email_lookup_with_fallback(email)
44
+ file_path = File.join(__dir__, '../../../data/email_mapper.yml')
45
+ email_mapper = YAML.load_file(file_path)
46
+ email_hit = email_mapper.find { |mapping| mapping['slack_email'] == email.delete_suffix('@gitlab.com') }
47
+ email = "#{email_hit['bamboo_email']}@gitlab.com" if email_hit
48
+
49
+ employees.find { |employee| employee['workEmail'] == email }
50
+ end
51
+
42
52
  def fetch_manager(team_member)
43
53
  active_team_members.find { |tm| tm['id'] == team_member['supervisorEId'] }
44
54
  end
@@ -71,7 +81,11 @@ module PeopleGroup
71
81
  retries = 0
72
82
 
73
83
  begin
74
- @employees ||= @client.report.custom(fields, 'JSON').reject { |employee| employee['lastName'] == 'Test-Gitlab' }
84
+ if @use_report
85
+ @employees ||= @client.report.find(@use_report, 'JSON', true)
86
+ else
87
+ @employees ||= @client.report.custom(fields, 'JSON').reject { |employee| employee['lastName'] == 'Test-Gitlab' }
88
+ end
75
89
  rescue Net::ReadTimeout, Bamboozled::GatewayError
76
90
  retry if (retries += 1) < MAX_RETRIES
77
91
  end
@@ -162,6 +176,14 @@ module PeopleGroup
162
176
  @client.employee.add_table_row(employee_id, 'customAdditionalInformation1', data)
163
177
  end
164
178
 
179
+ def additional_data(employee_id)
180
+ @client.employee.table_data(employee_id, 'employmentStatus')
181
+ end
182
+
183
+ def currency_conversion(employee_id)
184
+ @client.employee.table_data(employee_id, 'customCurrencyConversion')
185
+ end
186
+
165
187
  def add_bonus(team_member_id, comment)
166
188
  data = {
167
189
  customBonusdate: Date.today.to_s,
@@ -73,8 +73,8 @@ module PeopleGroup
73
73
  # If the candidate has any application that is active, we don't sync.
74
74
  return false if candidate['applications'].any? { |application| application['status'] == 'active' }
75
75
 
76
- # Check if candidate is hired for just one of their applications
77
- candidate['applications'].one? { |application| application['status'] == 'hired' }
76
+ # Check if candidate is hired for at least one of their applications
77
+ candidate['applications'].any? { |application| application['status'] == 'hired' }
78
78
  end
79
79
  end
80
80
  end
@@ -18,6 +18,17 @@ module PeopleGroup
18
18
  nil
19
19
  end
20
20
 
21
+ def bamboo_email_lookup_with_fallback(email)
22
+ file_path = File.join(__dir__, '../../../data/email_mapper.yml')
23
+ email_mapper = YAML.load_file(file_path)
24
+ email_hit = email_mapper.find { |mapping| mapping['bamboo_email'] == email.delete_suffix('@gitlab.com') }
25
+ email = "#{email_hit['slack_email']}@gitlab.com" if email_hit
26
+
27
+ @client.users_lookupByEmail(email: email)
28
+ rescue ::Slack::Web::Api::Errors::SlackError
29
+ nil
30
+ end
31
+
21
32
  def find_user_by_id(id)
22
33
  @client.users_info(user: id)
23
34
  rescue ::Slack::Web::Api::Errors::SlackError
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PeopleGroup
4
4
  module Connectors
5
- VERSION = '0.1.29'
5
+ VERSION = '0.1.34'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peoplegroup-connectors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.29
4
+ version: 0.1.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - lien van den steen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-25 00:00:00.000000000 Z
11
+ date: 2021-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -159,6 +159,7 @@ extra_rdoc_files: []
159
159
  files:
160
160
  - LICENSE.txt
161
161
  - README.md
162
+ - data/email_mapper.yml
162
163
  - lib/peoplegroup/connectors.rb
163
164
  - lib/peoplegroup/connectors/bamboo.rb
164
165
  - lib/peoplegroup/connectors/gitlab.rb