Skip to content

Commit

Permalink
Adding the Rake tasks pomegranate:reindex (for reindexing a Solr Docu…
Browse files Browse the repository at this point in the history
…ment using a IIIF Manifest URL) and pomegranate:sidecar_clean_references (for removing deprecated Catalog/Orangelight electronic_access_1display values)
  • Loading branch information
jrgriffiniii committed Feb 19, 2019
1 parent d40f975 commit b02a7ed
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/tasks/dev.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@ if Rails.env.development? || Rails.env.test?
require "factory_bot"

namespace :pomegranate do
desc 'Reindex a resource from a IIIF Manifest URL within an Exhibit'
task :reindex, %i[manifest exhibit] => [:environment] do |_t, args|
manifest = args[:manifest]
exhibit_slug = args[:exhibit]
exhibit = Spotlight::Exhibit.find_by(slug: exhibit_slug)
iiif_resource = IIIFResource.find_or_initialize_by(url: manifest, exhibit: exhibit)
iiif_resource.save_and_index_now
puts "Reindexed the document for #{manifest}"
end

desc 'Clear the SolrDocumentSidecar reference fields'
task :sidecar_clean_references, [:exhibit] => [:environment] do |_t, args|
exhibit_slug = args[:exhibit]
exhibit = Spotlight::Exhibit.find_by(slug: exhibit_slug)
sidecars = Spotlight::SolrDocumentSidecar.where(exhibit: exhibit)
sidecars.each do |sidecar|
sidecar.data
valid_data = sidecar.data.reject do |k, v|
k.include?('references') && v.include?('iiif_manifest_paths')
end
next unless sidecar.data != valid_data
sidecar.data = valid_data
sidecar.save
puts "Updated the SolrDocumentSidecar for #{sidecar.document_id}"
end
end

desc 'Make first user a site admin'
task site_admin: :environment do
user = User.first
Expand Down

0 comments on commit b02a7ed

Please sign in to comment.