Skip to content

Commit

Permalink
Thumbnails: harvest all task
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlarson committed Dec 5, 2023
1 parent d30b65a commit 05ec312
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
8 changes: 1 addition & 7 deletions app/jobs/geoblacklight_admin/store_image_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ class StoreImageJob < ApplicationJob
queue_as :default

def perform(solr_document_id)
document = Geoblacklight::SolrDocument.find(solr_document_id)

metadata = {}
metadata["solr_doc_id"] = document.id
metadata["solr_version"] = document.sidecar.version

document.sidecar.image_state.transition_to!(:queued, metadata)
document = Document.find_by_friendlier_id(solr_document_id)
GeoblacklightAdmin::ImageService.new(document).store
end
end
Expand Down
30 changes: 30 additions & 0 deletions lib/tasks/geoblacklight_admin/images.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require "csv"

namespace :geoblacklight_admin do
namespace :images do
desc "Harvest image for specific document"
task harvest_doc_id: :environment do
GeoblacklightAdmin::StoreImageJob.perform_later(ENV["DOC_ID"])
end

desc "Harvest all images"
task harvest_all: :environment do
query = "*:*"
index = Geoblacklight::SolrDocument.index
results = index.send_and_receive(index.blacklight_config.solr_path,
q: query,
fl: "*",
rows: 100_000_000)
# num_found = results.response[:numFound]
# doc_counter = 0
results.docs.each do |document|
sleep(1)
begin
GeoblacklightAdmin::StoreImageJob.perform_later(document["id"])
rescue Blacklight::Exceptions::RecordNotFound
next
end
end
end
end
end

0 comments on commit 05ec312

Please sign in to comment.