Skip to content

Commit eac4f5d

Browse files
committed
handles emeritus faculty without umichhr data
1 parent 92fdfbd commit eac4f5d

File tree

7 files changed

+79
-4
lines changed

7 files changed

+79
-4
lines changed

lib/patron.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
class Patron
1616
INST_ROLE_MAP = YAML.load_file("./config/umich_inst_roles_map.yaml")
1717

18+
def self.inst_role_map
19+
INST_ROLE_MAP
20+
end
21+
1822
def self.inst_roles_for(data)
1923
INST_ROLE_MAP.select do |inst_role|
2024
data["umichinstroles"].include?(inst_role["key"])

lib/patron/employee.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def hr_criteria(hr_item)
1414
raise NotImplementedError
1515
end
1616

17+
def inst_role_base
18+
raise NotImplementedError
19+
end
20+
1721
[
1822
"statistic_category",
1923
"user_group",
@@ -26,7 +30,7 @@ def hr_criteria(hr_item)
2630
end
2731

2832
def campus_code
29-
HR_CAMPUS_MAP[hr_data.campus.downcase]
33+
HR_CAMPUS_MAP.dig(hr_data&.campus&.downcase) || campus_code_from_inst_role
3034
end
3135

3236
def email_type
@@ -46,7 +50,7 @@ def umich_address_type
4650
end
4751

4852
def job_description
49-
"#{hr_data.deptDescription} (#{hr_data.deptId})"
53+
"#{hr_data.deptDescription} (#{hr_data.deptId})" if hr_data
5054
end
5155

5256
def hr_attribute
@@ -81,5 +85,10 @@ def hr_data
8185
result
8286
end
8387
end
88+
89+
def campus_code_from_inst_role
90+
umichinstrole = @data["umichinstroles"].first { |x| inst_role_base.match?(x) }
91+
Patron.inst_role_map.first { |x| x["key"] == umichinstrole }["campus"]
92+
end
8493
end
8594
end

lib/patron/faculty.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ class Faculty < Patron::Employee
2626
"201110" => "EM", # ASSOC PROF EMERITUS/A
2727
"201120" => "EM" # ASST PROF EMERITUS/A
2828
}
29+
30+
def includable?
31+
!!emeritus_umich_title || super
32+
end
33+
34+
def inst_role_base
35+
"Faculty"
36+
end
37+
2938
def role
3039
"faculty"
3140
end
@@ -35,7 +44,7 @@ def user_group
3544
end
3645

3746
def statistic_category
38-
JOBCODE_TO_STATISTIC_CATEGORY[hr_data.jobcode] || "FA"
47+
emeritus_umich_title || JOBCODE_TO_STATISTIC_CATEGORY[hr_data.jobcode] || "FA"
3948
end
4049

4150
def hr_criteria(hr_item)
@@ -45,5 +54,9 @@ def hr_criteria(hr_item)
4554
def exclude_reason
4655
"no_faculty_job_category" unless includable?
4756
end
57+
58+
def emeritus_umich_title
59+
"EM" if ["emeritus", "emerita"].any? { |em| /em/i.match?(@data["umichtitle"]&.first) }
60+
end
4861
end
4962
end

lib/patron/sponsored_affiliate.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class SponsoredAffiliate < Patron::Employee
1414
# "Subscribers",
1515
"Temporary Staff"
1616
]
17+
def inst_role_base
18+
"SponsoredAffiliate"
19+
end
20+
1721
def user_group
1822
"01"
1923
end

lib/patron/staff_person.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ class StaffPerson < Patron::Employee
66
"205800" # GRAD STU STAFF ASST
77
]
88

9+
def inst_role_base
10+
"RegularStaff"
11+
end
12+
913
def role
1014
"staff"
1115
end

lib/patron/temporary_staff_person.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
class Patron
22
class TemporaryStaffPerson < Patron::Employee
3+
def inst_role_base
4+
"TemporaryStaff"
5+
end
6+
37
def user_group
48
"14"
59
end

spec/patron/faculty_spec.rb

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,23 @@
1818
@patron["umichhr"][0].sub!("UM_ANN-ARBOR", "UM_FLINT")
1919
expect(subject.campus_code).to eq("UMFL")
2020
end
21+
it "comes from first faculty matched inst role when not hr data" do
22+
@patron["umichinstroles"].push("FacultyAA")
23+
@patron["umichhr"] = []
24+
expect(subject.campus_code).to eq("UMAA")
25+
end
2126
end
2227
context "#includable?" do
2328
it "is true when it has a Faculty job category" do
2429
expect(subject.includable?).to eq(true)
2530
end
31+
it "is true when emeritus in job title, even without job category" do
32+
@patron["umichhr"] = []
33+
@patron["umichtitle"] = [
34+
"PROFESSOR EMERITUS OF ENGLISH, COLLEGE OF ARTS AND SCIENCES, THE UNIVERSITY OF MICHIGAN-FLINT"
35+
]
36+
expect(subject.includable?).to eq(true)
37+
end
2638
it "is false when there is no appropriate job category" do
2739
@patron["umichhr"][0].sub!("jobCategory=Faculty", "jobCategory=Staff")
2840
expect(subject.includable?).to eq(false)
@@ -42,6 +54,10 @@
4254
it "returns a job_description from HR data" do
4355
expect(subject.job_description).to eq("Library Info Tech - AIM (470430)")
4456
end
57+
it "returns an empty string when there's no hr data" do
58+
@patron["umichhr"] = []
59+
expect(subject.job_description).to be_nil
60+
end
4561
end
4662
context "#hr_data" do
4763
it "returns appropriate object for staff" do
@@ -52,11 +68,32 @@
5268
it "returns FA" do
5369
expect(subject.statistic_category).to eq("FA")
5470
end
55-
it "handles an emeritus" do
71+
it "handles an emeritus in jobcode" do
5672
# Professor Emeritus
5773
@patron["umichhr"][0].sub!("jobcode=101904", "jobcode=201070")
5874
expect(subject.statistic_category).to eq("EM")
5975
end
76+
context "#emeritus in job title" do
77+
it "handles Emeritus in job title" do
78+
@patron["umichtitle"] = [
79+
"Ruth Dow Doan Professor of Biologic Nanotechnology, Professor Emeritus of Internal Medicine, Director, MI Nanotechnology Institute, Medical School and Professor Emeritus of Biomedical Engineering, College of Engineering"
80+
81+
]
82+
expect(subject.statistic_category).to eq("EM")
83+
end
84+
it "handles Emerita" do
85+
@patron["umichtitle"] = [
86+
"Professor Emerita of Psychology and Professor Emerita of Asian Languages and Cultures, College of Literature, Science, and the Arts"
87+
]
88+
expect(subject.statistic_category).to eq("EM")
89+
end
90+
it "handles all caps" do
91+
@patron["umichtitle"] = [
92+
"PROFESSOR EMERITUS OF ENGLISH, COLLEGE OF ARTS AND SCIENCES, THE UNIVERSITY OF MICHIGAN-FLINT"
93+
]
94+
expect(subject.statistic_category).to eq("EM")
95+
end
96+
end
6097
it "handles an adjunct faculty" do
6198
# Adjunct Faculty
6299
@patron["umichhr"][0].sub!("jobcode=101904", "jobcode=201030")

0 commit comments

Comments
 (0)