Skip to content

Commit

Permalink
HYC-1398: Add short label to department service (#777)
Browse files Browse the repository at this point in the history
* Add short label - need to use it now

* Use short label to index to Solr

- This removes the temptation to change the permanent ID of a department because of wanting to change the display

* Test for uncontrolled terms in affiliation for indexing

* Clearer naming and documentation for departments service

* Turn off cache to try to get CI green

* Rebase on main and get green
  • Loading branch information
maxkadel authored Apr 5, 2022
1 parent 8e56c33 commit 0a7baf8
Show file tree
Hide file tree
Showing 11 changed files with 1,706 additions and 1,218 deletions.
2 changes: 1 addition & 1 deletion app/services/affiliation_remediation_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def mappable_affiliation?(affiliation)

return false if affiliation.empty?

mapping = DepartmentsService.label(affiliation)
mapping = DepartmentsService.term(affiliation)
mapping ? true : false
end

Expand Down
14 changes: 13 additions & 1 deletion app/services/departments_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,31 @@ def self.select_all_options
end
end

# The permanent identifier for the term, stored in Fedora. This identifier should not be changed.
def self.identifier(term)
authority.all.reject { |item| item['active'] == false }.select { |department| department['label'] == term }.first['id']
rescue StandardError
nil
end

def self.label(id)
# The full term associated with the identifier. This is currently used in the display of People objects
def self.term(id)
authority.find(id).fetch('term')
rescue StandardError
Rails.logger.warn "DepartmentsService: cannot find '#{id}'"
nil
end

# The short version of the term associated with the identifier. These short terms were initially populated with the same
# values as the identifiers, but unlike the identifiers, these values *can* be changed without negative effects.
# This values is indexed to solr for department faceting.
def self.short_label(id)
authority.find(id).fetch('short_label')
rescue KeyError
Rails.logger.warn "DepartmentsService: cannot find '#{id}'"
nil
end

def self.include_current_value(value, _index, render_options, html_options)
unless value.blank?
html_options[:class] << ' force-select'
Expand Down
2 changes: 1 addition & 1 deletion app/services/hyc_crawler_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def self.person_affiliations_by_type(object, person_type)
end

def self.unmappable_affiliations(affiliations)
affiliations.map { |affil| DepartmentsService.label(affil) ? nil : affil }.compact
affiliations.map { |affil| DepartmentsService.term(affil) ? nil : affil }.compact
end

def self.all_person_affiliations(object)
Expand Down
2 changes: 1 addition & 1 deletion app/services/tasks/doi_create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def parse_people(work, person_field)
other_affil = p_json['other_affiliation']&.first

if !affil.blank?
expanded_affils = DepartmentsService.label(affil)
expanded_affils = DepartmentsService.term(affil)
person[:affiliation] = expanded_affils.split('; ') unless expanded_affils.nil?
elsif !other_affil.blank?
person[:affiliation] = [other_affil]
Expand Down
Loading

0 comments on commit 0a7baf8

Please sign in to comment.