Skip to content

Commit

Permalink
Merge pull request #96 from LD4P/loc-updates
Browse files Browse the repository at this point in the history
Enable RWO lookups (#395)
  • Loading branch information
Baroquem authored Apr 1, 2024
2 parents 17dd9db + f9bdeb2 commit e980413
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/qa/authorities/loc/generic_authority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def build_query_url(q)
escaped_query = ERB::Util.url_encode(q)
authority = Loc.get_authority(subauthority)
rdftype = Loc.get_rdftype(subauthority)
authority_fragment = Loc.get_url_for_authority(authority) + ERB::Util.url_encode(authority)
use_authority = authority == 'agents' ? 'names' : authority
authority_fragment = Loc.get_url_for_authority(use_authority) + ERB::Util.url_encode(use_authority)
rdftype_fragment = "&q=rdftype:#{ERB::Util.url_encode(rdftype)}" if rdftype
"https://id.loc.gov/search/?q=#{escaped_query}&q=#{authority_fragment}#{rdftype_fragment}&format=json"
end
Expand Down Expand Up @@ -87,6 +88,11 @@ def loc_response_to_qa(data)

response["uri"] = (data.links.find { |l| l["type"].nil? } || data.links[0])["href"] if data.links.present?

if subauthority.include? 'agents'
response['id'].gsub!('authorities/names', 'rwo/agents')
response['uri'].gsub!('authorities/names', 'rwo/agents')
end

response
end
end
Expand Down
6 changes: 6 additions & 0 deletions lib/qa/authorities/loc_subauthority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def get_rdftype(authority)

def authorities
[
"agents",
"classification",
"childrensSubjects",
"demographicTerms",
Expand Down Expand Up @@ -143,6 +144,11 @@ def preservation # rubocop:disable Metrics/MethodLength

def rdftypes
[
"agents_ConferenceName",
"agents_CorporateName",
"agents_FamilyName",
"agents_Geographic",
"agents_PersonalName",
"names_ConferenceName",
"names_CorporateName",
"names_FamilyName",
Expand Down

0 comments on commit e980413

Please sign in to comment.