Skip to content

Commit

Permalink
Merge pull request #5235 from pulibrary/5218-bl-upgrade
Browse files Browse the repository at this point in the history
Upgrade blacklight to 7.25
  • Loading branch information
eliotjordan authored Jul 12, 2022
2 parents 82ee3ae + 27a1eb6 commit ff3655d
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
FIGGY_DB_HOST: localhost
FIGGY_DB_USERNAME: figgy
FIGGY_DB_PASSWORD: ""
PSQL_PAGER: ''
- image: postgres:10.6-alpine
environment:
POSTGRES_USER: figgy
Expand Down Expand Up @@ -67,6 +68,7 @@ jobs:
FIGGY_DB_USERNAME: figgy
FIGGY_DB_PASSWORD: ""
MEDIAINFO_PATH: /usr/bin/mediainfo
PSQL_PAGER: ''
- image: postgres:10.6-alpine
environment:
POSTGRES_USER: figgy
Expand Down Expand Up @@ -158,6 +160,7 @@ jobs:
FIGGY_DB_HOST: localhost
FIGGY_DB_USERNAME: figgy
FIGGY_DB_PASSWORD: ""
PSQL_PAGER: ''
steps:
- browser-tools/install-browser-tools
- attach_workspace:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "https://rubygems.org"

gem "autoprefixer-rails"
gem "bagit", "~> 0.4"
gem "blacklight", "7.11.1"
gem "blacklight", "7.25.2"
gem "blacklight_range_limit"
gem "bootstrap", "~> 4.0"
gem "bootstrap_form", "~> 4.5.0"
Expand Down
12 changes: 8 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,16 @@ GEM
rubocop-performance
rubocop-rails
rubocop-rspec
blacklight (7.11.1)
blacklight (7.25.2)
deprecation
globalid
hashdiff
i18n (>= 1.7.0)
jbuilder (~> 2.7)
kaminari (>= 0.15)
rails (>= 5.1, < 7)
view_component
ostruct (>= 0.3.2)
rails (>= 5.1, < 7.1)
view_component (~> 2.43)
blacklight-access_controls (6.0.1)
blacklight (> 6.0, < 8)
cancancan (>= 1.8)
Expand Down Expand Up @@ -649,6 +652,7 @@ GEM
optimist (3.0.1)
orm_adapter (0.5.0)
os (1.1.4)
ostruct (0.5.5)
parallel (1.21.0)
parser (3.1.1.0)
ast (~> 2.4.1)
Expand Down Expand Up @@ -994,7 +998,7 @@ DEPENDENCIES
bagit (~> 0.4)
benchmark-ips
bixby (~> 3.0.0)
blacklight (= 7.11.1)
blacklight (= 7.25.2)
blacklight_iiif_search
blacklight_range_limit
bootsnap
Expand Down
27 changes: 19 additions & 8 deletions app/controllers/bulk_edit_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class BulkEditController < ApplicationController
delegate :search_builder, :repository, to: :search_service

def resources_edit
(solr_response, _document_list) = search_service.search_results do |search_builder|
search_builder.with(q: params["q"], f: params["f"])
(solr_response, _document_list) = search_service.search_results do |builder|
builder.with(edit_params)
end
@resources_count = solr_response["response"]["numFound"]
end
Expand All @@ -29,8 +29,17 @@ def resources_update

private

# used by search state to access filter fields
def blacklight_config
@blacklight_config ||= CatalogController.new.blacklight_config
end

def edit_params
params.permit(:q, f: {})
end

def search_params
params.permit(search_params: {})["search_params"]
@search_params ||= params.permit(search_params: {})["search_params"]
end

def load_collections
Expand All @@ -43,9 +52,12 @@ def batches
builder = initial_builder
[].tap do |arr|
loop do
response = repository.search(builder)
arr << response.documents.map(&:id)
break if (builder.page * builder.rows) >= response["response"]["numFound"]
(solr_response, document_list) = search_service.search_results do |_builder|
builder # use the builder we made
end

arr << document_list.map(&:id)
break if (builder.page * builder.rows) >= solr_response["response"]["numFound"]
builder.start = builder.rows * builder.page
builder.page += 1
end
Expand All @@ -54,8 +66,7 @@ def batches
end

def initial_builder
builder_params = { q: params["search_params"]["q"], f: params["search_params"]["f"] }
builder = search_builder.with(builder_params)
builder = search_builder.with(search_params)
builder.rows = params["batch_size"] || 50
builder
end
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/figgy/form/detect_duplicates.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DuplicateResourceDetector {

setQueryUrl() {
this.value = this.$element.val()
this.queryUrl = `/catalog?f[${this.field}][]=${this.value}`
this.queryUrl = `/catalog?q=${this.field}:${this.value}`
if(this.existing)
this.queryUrl += `&q=NOT+id:${this.existing}`
}
Expand Down
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
Rails.application.configure do
config.cache_classes = true
config.cache_classes = false
config.eager_load = false
config.public_file_server.enabled = true
config.public_file_server.headers = {
Expand Down
6 changes: 4 additions & 2 deletions config/initializers/analyze_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Monkey patch AnalyzeJob so that an ActiveJob::DeserializationError is rescued and
# does not cause the job to be moved to the retry queue. This is used mainly for
# OcrRequest blobs that are purged before AnalyzeJob is run.
ActiveStorage::AnalyzeJob.class_eval do
discard_on ActiveJob::DeserializationError
Rails.application.config.to_prepare do
ActiveStorage::AnalyzeJob.class_eval do
discard_on ActiveJob::DeserializationError
end
end
7 changes: 5 additions & 2 deletions config/initializers/riiif_initializer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# frozen_string_literal: true
require "mini_magick"
Riiif::Image.file_resolver = RiiifResolver.new
Riiif::Image.file_resolver.base_path = Figgy.config["derivative_path"]

Rails.application.config.to_prepare do
Riiif::Image.file_resolver = RiiifResolver.new
Riiif::Image.file_resolver.base_path = Figgy.config["derivative_path"]
end
2 changes: 1 addition & 1 deletion spec/features/bulk_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
it "updates the object" do
collection2 = FactoryBot.create_for_repository(:collection)
visit bulk_edit_resources_edit_path("q" => "", "f[member_of_collection_titles_ssim][]" => "My Collection")
expect(page).to have_content "You searched for"
expect(page).to have_content "Bulk edit 1 resources"
page.check("mark_complete")
page.select collection2.title.first, from: "append_collection_ids", visible: false
accept_alert do
Expand Down

0 comments on commit ff3655d

Please sign in to comment.