-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dba6857
commit b152166
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class SearchBuilder | ||
class JoinChildrenQuery | ||
attr_reader :parent_query | ||
def initialize(parent_query) | ||
@parent_query = parent_query | ||
end | ||
|
||
def to_s | ||
queries.map do |query| | ||
"(#{dismax_join(send(query))})" | ||
end.join(" OR ") | ||
end | ||
|
||
private | ||
|
||
def queries | ||
[ | ||
:main_query, | ||
:query_children | ||
] | ||
end | ||
|
||
def dismax_join(query) | ||
"#{query}{!dismax}#{parent_query}" | ||
end | ||
|
||
def main_query | ||
"" | ||
end | ||
|
||
def query_children | ||
"{!join from=collection_id_ssim to=id}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe CatalogController do | ||
context "with mvw", vcr: { cassette_name: 'mvw' } do | ||
let(:url) { "https://hydra-dev.princeton.edu/concern/multi_volume_works/f4752g76q/manifest" } | ||
it "hides scanned resources with parents" do | ||
exhibit = Spotlight::Exhibit.create title: 'Exhibit A' | ||
resource = IIIFResource.new manifest_url: url, exhibit: exhibit | ||
expect(resource.save_and_index).to be_truthy | ||
|
||
get :index, q: "", exhibit_id: exhibit.id | ||
|
||
expect(document_ids).to eq [resource.to_solr.to_a.first[:id]] | ||
end | ||
it "returns MVW from metadata found in volume" do | ||
exhibit = Spotlight::Exhibit.create title: 'Exhibit A' | ||
resource = IIIFResource.new manifest_url: url, exhibit: exhibit | ||
expect(resource.save_and_index).to be_truthy | ||
|
||
get :index, q: "SR1", exhibit_id: exhibit.id | ||
|
||
expect(document_ids).to eq [resource.to_solr.to_a.first[:id]] | ||
end | ||
end | ||
|
||
def document_ids | ||
assigns[:document_list].map do |x| | ||
x["id"] | ||
end | ||
end | ||
end |