peoplegroup-hris 0.1.0 → 0.1.1

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: 57dcac72a80f8b12dfaf75e63f1756ff53c1d9188220e8272fd08b0ddbb34a04
4
- data.tar.gz: 64f37272850f9bd2e2e6cea2b5a5dd57d897a800e827aa3851547572959c8340
3
+ metadata.gz: af2fbb3f87a48810923818791b9f64806dee057252b94823d468a2fac71d17c3
4
+ data.tar.gz: 4a8ce9cdeda8f15c441d6f1380b2f3c4b2723f3131205b40e5408407e82be8e3
5
5
  SHA512:
6
- metadata.gz: c0321306d4c9b6b75b72f6cccb3f9a51c5d514be9f70a3b888150fc1a1f883f0d08a3595076ebb38a321268350bb53360ab849bea8f779dc7e38db2f2944c955
7
- data.tar.gz: 2ab6f07293fef1cc33c219d29d632292b8cb2257c8aea29ac442642163879f9ba31c736f5bd456b8036359cc3ec4f628bc5738296a38c6ed1a7363034b89867f
6
+ metadata.gz: c5d4b55b17e3edfa6973a19fae9a01e7f812101346bccf16a7adcf80cd100db07008d0ddfb5fe95f6b7d672dd72d7dacc333ae22dc308a1c722ff774a642a267
7
+ data.tar.gz: a012fa65e9616a58437f8a9f15bc5863123d050cddf2241079583b3e9a661ce6408abab8e1885d232ac58f811a2c586b892022e64e13456665ce47a78c6a5e3f
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'bamboozled'
4
4
  require_relative "hr_tool"
5
+ require_relative 'wrappers/bamboo_team_member'
5
6
 
6
7
  module PeopleGroup
7
8
  module HRIS
@@ -13,14 +14,7 @@ module PeopleGroup
13
14
  end
14
15
 
15
16
  def self.map_to_team_member(data)
16
- team_member = TeamMember.new
17
- team_member.department = data['department']
18
- team_member.division = data['division']
19
- team_member.first_name = data['preferredName'] || data['firstName']
20
- team_member.last_name = data['customPreferredLastName'] || data['lastName']
21
- team_member.full_name = "#{team_member.first_name} #{team_member.last_name}"
22
- team_member.active = data['status'] == 'Active'
23
- team_member
17
+ PeopleGroup::HRIS::Wrappers::BambooTeamMember.new(data)
24
18
  end
25
19
 
26
20
  private
@@ -3,8 +3,6 @@
3
3
  module PeopleGroup
4
4
  module HRIS
5
5
  class HRTool
6
- TeamMember = Struct.new(:department, :division, :first_name, :last_name, :full_name, :active)
7
-
8
6
  def self.all
9
7
  raise NotImplementedError
10
8
  end
@@ -7,14 +7,19 @@ module PeopleGroup
7
7
  @@all ||= hr_tool.all.map! { |data| hr_tool.map_to_team_member(data) }
8
8
  end
9
9
 
10
- def self.all_active
11
- all.select { |team_member| team_member.active }
10
+ def self.active
11
+ all.select { |team_member| team_member.active? }
12
+ end
13
+
14
+ def self.active_and_current
15
+ today = Date.current
16
+ all.select { |team_member| team_member.active? && team_member.start_date <= today }
12
17
  end
13
18
 
14
19
  private
15
20
 
16
21
  def self.hr_tool
17
- BambooHR
22
+ BambooHR # TODO can we set this on config
18
23
  end
19
24
  end
20
25
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Peoplegroup
4
4
  module Hris
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
@@ -0,0 +1,70 @@
1
+ require_relative 'team_member'
2
+
3
+ module PeopleGroup
4
+ module HRIS
5
+ module Wrappers
6
+ class BambooTeamMember < TeamMember
7
+ def initialize(data)
8
+ @data = data
9
+ end
10
+
11
+ MAPPED_ITEMS = ['department', 'division']
12
+ MAPPED_ITEMS.each do |item|
13
+ define_method("#{item}") do
14
+ @data[item]
15
+ end
16
+ end
17
+
18
+ def team_member_id
19
+ @data['id']
20
+ end
21
+
22
+ def first_name
23
+ @data['preferredName'] || @data['firstName']
24
+ end
25
+
26
+ def last_name
27
+ @data['customPreferredLastName'] || @data['lastName']
28
+ end
29
+
30
+ def active?
31
+ @data['status'] == 'Active'
32
+ end
33
+
34
+ def start_date
35
+ return unless @data['hireDate']
36
+
37
+ Date.parse(@data['hireDate'])
38
+ end
39
+
40
+ def specialties
41
+ @data['customJobTitleSpecialty(Multi-Select)'] || @data['customJobTitleSpeciality'] || ''
42
+ end
43
+
44
+ def gitlab_username
45
+ @data['customGitLabUsername']
46
+ end
47
+
48
+ def work_email
49
+ @data['workEmail']
50
+ end
51
+
52
+ def offboarded?
53
+ today = Date.current
54
+ employment_statuses = hr_client.employee.table_data(team_member_id, 'employmentStatus')
55
+ return false if employment_statuses.size <= 1
56
+
57
+ employment_statuses.any? do |status|
58
+ ['Garden Leave', 'Terminated'].include?(status['employmentStatus']) && Date.parse(status['date']) >= today
59
+ end
60
+ end
61
+
62
+ private
63
+
64
+ def hr_client
65
+ @client ||= Bamboozled.client(subdomain: ENV['BAMBOO_SUBDOMAIN'], api_key: ENV['BAMBOO_API_KEY'])
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,21 @@
1
+ module PeopleGroup
2
+ module HRIS
3
+ module Wrappers
4
+ class TeamMember
5
+ REQUIRED_METHODS = %w[first_name last_name active? start_date
6
+ specialties, gitlab_username, work_email,
7
+ offboarded? department division team_member_id]
8
+
9
+ REQUIRED_METHODS.each do |method|
10
+ define_method("#{method}") do
11
+ raise NotImplementedError
12
+ end
13
+ end
14
+
15
+ def full_name
16
+ "#{first_name} #{last_name}"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peoplegroup-hris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-07-29 00:00:00.000000000 Z
11
+ date: 2021-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bamboozled-gitlab
@@ -122,6 +122,8 @@ files:
122
122
  - lib/peoplegroup/hris/hr_tool.rb
123
123
  - lib/peoplegroup/hris/team_members.rb
124
124
  - lib/peoplegroup/hris/version.rb
125
+ - lib/peoplegroup/hris/wrappers/bamboo_team_member.rb
126
+ - lib/peoplegroup/hris/wrappers/team_member.rb
125
127
  homepage: https://gitlab.com/gitlab-com/people-group/peopleops-eng/hris-gem'
126
128
  licenses:
127
129
  - MIT