peoplegroup-connectors 0.1.27 → 0.1.32

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: 5d75a768e48cbc915cd653e500736160f081ccb4ae5f0a9c974b444028245346
4
- data.tar.gz: 7c1bb07d0b7218319b91133b8ed799b88d8354f7beedd2102295305605b2acbc
3
+ metadata.gz: 24fc0303d37aaf2d6aa63b3babcf36ff18b086e084de6ac323440428c53926d4
4
+ data.tar.gz: 7974b2b210a74ab0236eb23cac227eb788332ddf0412609437139d0dc4a04ac4
5
5
  SHA512:
6
- metadata.gz: 10090f999bfa39337629672c26fe816a55475fd53cff8021273eb9eff5229237e89ce476176ff6212e1e1d1f06dea61325a8b713899265f836e5fd8628a433c1
7
- data.tar.gz: 859d0f1fb5ac3249d7d70b74420fa3627e151669e5111aa2413026c07e20f022b83e4c149a65434e1d9666f3235bae60d7440ba5dde2d299957dd9b3aa76fcf4
6
+ metadata.gz: a26c436c53c04da6889f179cad06c13f6a1b7d3f9fa6e12cfbfa2436d6df8e24311b3eebeabbaae5bb8cd2cc289b009635b64c0d581c212b5d3a518a4ce1ad5c
7
+ data.tar.gz: 80eb3e35a56dae8b36a4c50a05b6f052275f135435b2ca0821a9e275ddcce7941bfbb520a56652e9f035e5071f7e13e0a616d2e59e20d0930731b550110318ee
@@ -0,0 +1,4 @@
1
+ - slack_email: cristiano
2
+ bamboo_email: ccasella
3
+ - slack_email: kencjohnston
4
+ bamboo_email: kjohnston
@@ -39,6 +39,15 @@ module PeopleGroup
39
39
  end
40
40
  alias_method :search_team_member_by_field, :search_employee_by_field
41
41
 
42
+ def slack_email_lookup_with_fallback(email)
43
+ file_path = File.join(__dir__, '../../../data/email_mapper.yml')
44
+ email_mapper = YAML.load_file(file_path)
45
+ email_hit = email_mapper.find { |mapping| mapping['slack_email'] == email.delete_suffix('@gitlab.com') }
46
+ email = email_hit['bamboo_email'] if email_hit
47
+
48
+ employees.find { |employee| employee['workEmail'] == email }
49
+ end
50
+
42
51
  def fetch_manager(team_member)
43
52
  active_team_members.find { |tm| tm['id'] == team_member['supervisorEId'] }
44
53
  end
@@ -5,6 +5,8 @@ require 'gitlab'
5
5
  module PeopleGroup
6
6
  module Connectors
7
7
  class GitLab
8
+ attr_accessor :client
9
+
8
10
  MAX_RETRIES = 3
9
11
 
10
12
  API_URL = ENV['GITLAB_API_V4_URL'] || 'https://gitlab.com/api/v4'
@@ -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'] 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.27'
5
+ VERSION = '0.1.32'
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.27
4
+ version: 0.1.32
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-12 00:00:00.000000000 Z
11
+ date: 2021-03-29 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