Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLAC-677: refactor access condition getting #481

Merged
merged 2 commits into from
Jun 28, 2024
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 app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class CatalogController < ApplicationController
config.add_summary_field "language", field: "language_ssim"
config.add_summary_field "prefercite", field: "prefercite_html_tesm", helper_method: :render_html_tags
config.add_summary_field "availability", field: "availability_status", accessor: :availability_status
config.add_summary_field "accessconditions", field: "access_conditions", accessor: :access_conditions
config.add_summary_field "accessconditions", field: "access_conditions_ssim"
config.add_summary_field "cult_sens_adv_notice",
label: I18n.t("ead_notes.cultural_sens_adv_notice"),
helper_method: :render_html_tags,
Expand Down
6 changes: 0 additions & 6 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,4 @@ def availability_status

CatalogueServicesClient.new.get_requestable(instance_id: self["folio_instance_id_ssi"], holdings_id: holdings, item_id: item)
end

def access_conditions
holdings, _item = CatalogueServicesClient.new.get_item_ids(instance_id: self["folio_instance_id_ssi"])

CatalogueServicesClient.new.get_access_conditions(instance_id: self["folio_instance_id_ssi"], holdings_id: holdings)
end
end
12 changes: 0 additions & 12 deletions app/services/catalogue_services_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ def get_item_ids(instance_id:)
[item_id, holding_id]
end

def get_access_conditions(instance_id:, holdings_id:)
all_holdings = get_holdings(instance_id: instance_id)

# find holdings record
holding = all_holdings.find { |h| h["id"] == holdings_id }

# find item record
item = holding["notes"].find { |i| i["holdingsNoteType"] == "Restriction" }

item ? item["note"] : nil
end

def related_docs(pid:)
conn = setup_connection

Expand Down
16 changes: 0 additions & 16 deletions spec/services/catalogue_services_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,6 @@
end
end

describe "#get_access_conditions" do
before do
cat_response = IO.read("spec/files/catalogue_services/08aed703-3648-54d0-80ef-fddb3c635731.json")
WebMock.stub_request(:get, /catservices.test\/catalogue-services\/folio\/instance\/08aed703-3648-54d0-80ef-fddb3c635731/)
.to_return(status: 200, body: cat_response, headers: {"Content-Type" => "application/json"})
end

it "returns the record's item id and holding id" do
expect(service.get_item_ids(instance_id: "08aed703-3648-54d0-80ef-fddb3c635731")).to eq %w[d6c97d9e-dfe6-5faa-9f0b-020b2bddbf8c 7460acfb-72b9-5dba-9089-603921fb47c7]
end

it "returns the record's access condition notes or nil" do
expect(service.get_access_conditions(instance_id: "08aed703-3648-54d0-80ef-fddb3c635731", holdings_id: "d6c97d9e-dfe6-5faa-9f0b-020b2bddbf8c")).to be_nil
end
end

describe "#related_docs" do
context "when there are related records" do
before do
Expand Down
Loading