Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ Note - to run the test suite you need to change the LDAP setting in your `.env`
- Move 'create_user_record' from user.rb to a separate class
- Add a check to make sure all necessary config settings are set!
- Setup a rake command to run the test suite
- Reduce some of the complexity in the complexity so I can remove some of the rubocop disables
- Reduce some of the complexity so I can remove some of the rubocop disables
2 changes: 1 addition & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Settings:
upload_host: "upload.lib.berkeley.edu"
upload_user: "ssullivan"
last_alma_purge: "2023-06-30"
application_version: "1.6.1"
application_version: "1.6.2"

# TODO - flesh this out
# http://docopt.org/
Expand Down
5 changes: 5 additions & 0 deletions config/ucpath_codes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,8 @@ EmployeeIDs Overlap With Inactive StudentIDs:
- "10152922"
- "10159568"
- "10162123"

# These jobs will always be considered "eligible" regardless
# of any student affiliations
Priority Job Codes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know we had this before, but i'm a little concerned about YAML keys containing spaces - could we rename this something like priority_job_codes or something similar? (i know we need to make similar changes throughout this file and in the code, too.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - that's definitely doable!

- "006761"
6 changes: 3 additions & 3 deletions lib/alma/xml_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def ensure_open!

def prolog_and_opening_tag
tag = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
tag += "<!-- GIT_SHA:#{ENV['GIT_SHA']} -->\n"
tag += "<!-- DOCKER_TAG:#{ENV['DOCKER_TAG']} -->\n"
tag += "<!-- VERSION: #{ENV['VERSION']} -->\n"
tag += "<!-- GIT_SHA:#{ENV.fetch('GIT_SHA', nil)} -->\n"
tag += "<!-- DOCKER_TAG:#{ENV.fetch('DOCKER_TAG', nil)} -->\n"
tag += "<!-- VERSION: #{ENV.fetch('VERSION', nil)} -->\n"
tag += "<!-- CHANGE_LOG_COUNT: #{change_log_count} -->\n"
tag += "<users>\n"
tag
Expand Down
5 changes: 1 addition & 4 deletions lib/ldap/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,18 @@ def fetch_ldap_rec(id)

private

# rubocop:disable Metrics/MethodLength
def ldap_connection
Net::LDAP.new host: host,
port: 636,
encryption: {
method: :simple_tls,
tls_options: OpenSSL::SSL::SSLContext::DEFAULT_PARAMS
method: :simple_tls
},
auth: {
method: :simple,
username: 'uid=library-hrms-epl,ou=applications,dc=berkeley,dc=edu',
password: pass
}
end
# rubocop:enable Metrics/MethodLength

def host
Config.secrets.ldap.host
Expand Down
31 changes: 24 additions & 7 deletions lib/ucpath/jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def eligible_job?

# Extract the data from the raw jobs into the fields we need
# config/ucpath_fields.yml contains the fields/jpath we want to extract
def find_eligible_job(raw_jobs)
raw_jobs.first.each do |job_hash|
job = OpenStruct.new(
Config.ucpath_job_fields.to_h do |field|
[field['name'], JsonPath.on(job_hash, field['jpath']).first || '']
end
)
def find_eligible_job(job_list)
priority_job_hash = find_priority_jobs(job_list)

return map_job_to_struct(priority_job_hash) if priority_job_hash

job_list.first.each do |job_hash|
job = map_job_to_struct(job_hash)

# First one - save it incase we don't find any eligible jobs!
@first_job ||= job
Expand Down Expand Up @@ -73,6 +73,23 @@ def check_if_eligible(j)
end
# rubocop :enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity

def find_priority_jobs(job_list)
job_list.flatten.find do |jh|
job_code = jh.dig('position', 'jobCode', 'code', 'code')
status = jh.dig('position', 'active', 'code')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, i'm not reading this right but should it be status = jh.dig('position', 'status', 'code'). Is it parsing ucpath_fields.yml?

Copy link
Contributor Author

@steve-sullivan steve-sullivan Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd think... but nope, here's the JSON from the API:

"position": {
        ...
	"active": {
		"code": "A",
		"description": "Active"
	},
	...
},

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm a little confused by this too - i din't think it's parsing that file, but i see a similar json path in that file. how are these two things related?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maria is correct, it's not parsing ucpath_fields.yml. The new function (find_priority_jobs) is going through the JSON that is returned from the UCPath/Jobs API (looking for any job that is active and in the priority list).

The JSONPath (from ucpath_fields.yml) is used to map data fields from the job hash (from the API) into an OpenStruct which gets passed back to the user object for further processing.


Config.check_ucpath_code('Priority Job Codes', job_code) && status == 'A'
end
end

def map_job_to_struct(job_hash)
OpenStruct.new(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenStruct is deprecated and will be removed from Ruby 3.5

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UGH...yeah. I'll open a ticket to eventually move from openstructs to structs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note - opened AP-584 for that work.

Config.ucpath_job_fields.to_h do |field|
[field['name'], JsonPath.on(job_hash, field['jpath']).first || '']
end
)
end

def fetch_jobs(id)
logger.info "#{id} - Fetching ucpath jobs data"
User.fetch_ucpath_jobs(id)
Expand Down
8 changes: 5 additions & 3 deletions lib/ucpath/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ def eligible?
def create_user_record
rec.primary_id = ucpath_rec.ucpath_employee_id

job_code = jobs.job.job_code || nil
priority_job = Config.check_ucpath_code('Priority Job Codes', job_code)

# STUDENT CHECK - berkeleyeduaffiliations in Student Affiliation (ldap_fields.yml)
if ldap&.berkeleyeduaffiliations
if !priority_job && ldap&.berkeleyeduaffiliations
ldap.berkeleyeduaffiliations.each do |affiliation|
if Config.student_affiated? affiliation
logger.info "#{id} - Ineligible: ldap student affiliation: #{affiliation}"
Expand All @@ -142,7 +145,6 @@ def create_user_record

# CONTINGENT WORKER CHECK
# AP-361: Thou Shalt not pass if the user has a Contingent Worker Job Code!
job_code = jobs.job.job_code || nil
if job_code && Config.check_ucpath_code('Contingent Worker Job Code', job_code)
logger.info "#{id} - Ineligible: Contingent Worker Job Code: #{job_code}"
return nil
Expand Down Expand Up @@ -222,7 +224,7 @@ def create_user_record
rec.identifiers = create_identifiers

# USER_ROLES - DROP (according to D.Rez, Alma should assign)
# USER_STATISTICS - TBD (addording to J.Gosselar these have yet to be determined)
# USER_STATISTICS - TBD (according to J.Gosselar these have yet to be determined)

# SET USER ELIGIBILITY
self.eligible = true
Expand Down
Loading