Skip to content

Commit 83ad8b6

Browse files
Skip employees when percentageOfFullTime is zero (#7)
* Skip employees when percentageOfFullTime is zero * Update version number for XML comments * Tweak full time check
1 parent 5052753 commit 83ad8b6

File tree

6 files changed

+58
-34
lines changed

6 files changed

+58
-34
lines changed

config/settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ settings:
66
upload_host: "upload.lib.berkeley.edu"
77
upload_user: "ssullivan"
88
last_alma_purge: "2023-06-30"
9-
application_version: "1.6.5"
9+
application_version: "1.6.6"
1010

1111
# TODO - flesh this out
1212
# http://docopt.org/

config/ucpath_fields.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,7 @@ job:
201201
dbdef: "VARCHAR(16)"
202202
status: OPTIONAL
203203

204-
# Needed....?
205-
# EmployeeIDs:
206-
# employee_rootnode: "//ar:response/emp:employees/emp:employee"
207-
# total_records_xpath: "//ar:offset/ar:total"
208-
# remaining_records_xpath: "//ar:offset/ar:remaining"
209-
# next_records_xpath: "//ar:offset/ar:next"
210-
# previous_records_xpath: "//ar:offset/ar:previous"
211-
# employee_id_xpath: "./p:identifiers/r:identifier[r:type/text()='hr-employee-id']/r:id"
204+
- name: percent_of_fulltime
205+
jpath: "$.position.percentOfFullTime"
206+
dbdef: "VARCHAR(16)"
207+
status: OPTIONAL

lib/ucpath/jobs.rb

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,44 @@ def choose_job(job1, job2)
6969
end
7070

7171
def eligible?(j)
72-
# There are 3 conditions that determine if a job is "not eligible":
73-
# 1. hrStatus/code = A
74-
return false unless j.hr_status_code == 'A'
72+
# There are 4 conditions that determine if a job is "not eligible":
73+
return false unless active_job?(j)
74+
return false unless valid_expected_end_date?(j)
75+
return false unless valid_org_relationship?(j)
76+
return false unless positive_full_time?(j)
7577

76-
# 2. If their Job record has an expectedEndDate, it must be on or after today's date.
78+
# If we got this far the job is eligible - hooray!
79+
true
80+
end
81+
82+
# 1. hrStatus/code = A
83+
def active_job?(j)
84+
j.hr_status_code == 'A'
85+
end
86+
87+
# 2. If their Job record has an expectedEndDate, it must be on or after today's date.
88+
def valid_expected_end_date?(j)
7789
end_date_str = j.expected_end_date.to_s
78-
return false if end_date_str != '' && Date.iso8601(end_date_str) <= Date.today
90+
return true if end_date_str.empty?
7991

80-
# 3. If their organizationRelationship/code = 'CWR' their jobCode must be within
81-
# the Visiting Scholar category
82-
# or UCB Academic Dept Affiliate Code (per SD-97)
83-
if j.org_relationship_code == 'CWR'
84-
visiting_scholar = Config.check_ucpath_code('visiting_scholar_job_code', j.job_code)
85-
academic_affiliate = Config.check_ucpath_code('ucb_academic_dept_affiliate_code', j.job_code)
92+
Date.iso8601(end_date_str) > Date.today
93+
end
8694

87-
return false unless visiting_scholar || academic_affiliate
88-
end
95+
# 3. If their organizationRelationship/code = 'CWR' their jobCode must be within
96+
# the Visiting Scholar category
97+
# or UCB Academic Dept Affiliate Code (per SD-97)
98+
def valid_org_relationship?(j)
99+
return true unless j.org_relationship_code == 'CWR'
89100

90-
# If we got this far the job is eligible - hooray!
91-
true
101+
visiting_scholar = Config.check_ucpath_code('visiting_scholar_job_code', j.job_code)
102+
academic_affiliate = Config.check_ucpath_code('ucb_academic_dept_affiliate_code', j.job_code)
103+
104+
visiting_scholar || academic_affiliate
105+
end
106+
107+
# 4. The job will be ineligible if the percentage of full time is zero
108+
def positive_full_time?(j)
109+
j.percent_of_fulltime.to_f.positive?
92110
end
93111

94112
def find_priority_jobs(job_list)

lib/ucpath/user.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ def create_user_record
143143

144144
job_code = jobs.job.job_code || nil
145145
priority_job = Config.check_ucpath_code('priority_job_codes', job_code)
146+
percent_of_fulltime = jobs.job.percent_of_fulltime.to_f
147+
148+
# PERCENT OF FULL TIME CHECK
149+
# AP-559 If an employee is in a position that is 0 FTE,
150+
# their record should should be filtered out from the UCPath files.
151+
if percent_of_fulltime.zero?
152+
logger.info "#{id} - Ineligible: Percentage of Full Time Check: #{percent_of_fulltime}"
153+
return nil
154+
end
146155

147156
# STUDENT CHECK - berkeleyeduaffiliations in Student Affiliation (ldap_fields.yml)
148157
if !priority_job && ldap&.berkeleyeduaffiliations

spec/data/ucpath/generic_jobs_2.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"code": "SMTOC",
1919
"description": "Simons Institute TOC"
2020
},
21+
"percentOfFullTime": 1.000000,
2122
"jobCode": {
2223
"code": {
2324
"code": "003252",

spec/lib/ucpath_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ def eligible(job)
603603
# Minimal structs to stand in for your “job” objects
604604
let(:choose_job_struct) { Struct.new(:expected_end_date) }
605605
let(:eligible_job_struct) do
606-
Struct.new(:hr_status_code, :expected_end_date, :org_relationship_code, :job_code)
606+
Struct.new(:hr_status_code, :expected_end_date, :org_relationship_code, :job_code, :percent_of_fulltime)
607607
end
608608

609609
describe '#choose_job' do
@@ -652,55 +652,55 @@ def eligible(job)
652652
end
653653

654654
context "when hr_status_code is not 'A'" do
655-
let(:job) { eligible_job_struct.new('I', '', '', 'ANY') }
655+
let(:job) { eligible_job_struct.new('I', '', '', 'ANY', 1.0) }
656656

657657
it 'returns false' do
658658
expect(eligible(job)).to be(false)
659659
end
660660
end
661661

662662
context "when hr_status_code is 'A' and expected_end_date is blank" do
663-
let(:job) { eligible_job_struct.new('A', '', '', 'ANY') }
663+
let(:job) { eligible_job_struct.new('A', '', '', 'ANY', 1.0) }
664664

665665
it 'returns true' do
666666
expect(eligible(job)).to be(true)
667667
end
668668
end
669669

670670
context "when hr_status_code is 'A' and expected_end_date is after today" do
671-
let(:job) { eligible_job_struct.new('A', '2026-03-01', '', 'ANY') }
671+
let(:job) { eligible_job_struct.new('A', '2026-03-01', '', 'ANY', 1.0) }
672672

673673
it 'returns true' do
674674
expect(eligible(job)).to be(true)
675675
end
676676
end
677677

678678
context "when hr_status_code is 'A' and expected_end_date is today" do
679-
let(:job) { eligible_job_struct.new('A', '2026-02-23', '', 'ANY') }
679+
let(:job) { eligible_job_struct.new('A', '2026-02-23', '', 'ANY', 1.0) }
680680

681681
it 'returns false (<= today is not eligible per implementation)' do
682682
expect(eligible(job)).to be(false)
683683
end
684684
end
685685

686686
context "when hr_status_code is 'A' and expected_end_date is before today" do
687-
let(:job) { eligible_job_struct.new('A', '2026-02-01', '', 'ANY') }
687+
let(:job) { eligible_job_struct.new('A', '2026-02-01', '', 'ANY', 1.0) }
688688

689689
it 'returns false' do
690690
expect(eligible(job)).to be(false)
691691
end
692692
end
693693

694694
context 'when org_relationship_code is blank and other conditions pass' do
695-
let(:job) { eligible_job_struct.new('A', '', '', 'ANY') }
695+
let(:job) { eligible_job_struct.new('A', '', '', 'ANY', 1.0) }
696696

697697
it 'returns true' do
698698
expect(eligible(job)).to be(true)
699699
end
700700
end
701701

702702
context "when org_relationship_code is 'CWR' and job_code is NOT in either allowlist" do
703-
let(:job) { eligible_job_struct.new('A', '', 'CWR', 'NOT_ALLOWED') }
703+
let(:job) { eligible_job_struct.new('A', '', 'CWR', 'NOT_ALLOWED', 1.0) }
704704

705705
before do
706706
allow(Config).to receive(:check_ucpath_code)
@@ -718,7 +718,7 @@ def eligible(job)
718718
end
719719

720720
context "when org_relationship_code is 'CWR' and job_code IS in visiting_scholar_job_code" do
721-
let(:job) { eligible_job_struct.new('A', '', 'CWR', 'ALLOWED') }
721+
let(:job) { eligible_job_struct.new('A', '', 'CWR', 'ALLOWED', 1.0) }
722722

723723
before do
724724
allow(Config).to receive(:check_ucpath_code)
@@ -736,7 +736,7 @@ def eligible(job)
736736
end
737737

738738
context "when org_relationship_code is 'CWR' and job_code IS in ucb_academic_dept_affiliate_code" do
739-
let(:job) { eligible_job_struct.new('A', '', 'CWR', 'ALLOWED') }
739+
let(:job) { eligible_job_struct.new('A', '', 'CWR', 'ALLOWED', 1.0) }
740740

741741
before do
742742
allow(Config).to receive(:check_ucpath_code)

0 commit comments

Comments
 (0)