Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save orangewolf/2264bd62d567f13a613391cd30bc8576 to your computer and use it in GitHub Desktop.
Save orangewolf/2264bd62d567f13a613391cd30bc8576 to your computer and use it in GitHub Desktop.
```ruby
switch!('adl')
queue = Valkyrie::IndexingAdapter.find(:redis_queue)
error_log = ActiveSupport::Logger.new("/app/samvera/hyrax-webapp/tmp/imports/indexing_errors.log")
@set = []
solr_indexer = Valkyrie::IndexingAdapter.find(:solr_index)
index_error_name = "toindex3929b765-8d25-48ab-986f-3ce4edf75a6b-error"
size = queue.connection.zrange(index_error_name, 0, -1).size
size.times do |i|
begin
@set = queue.connection.zpopmin(index_error_name, 1)
next [] if @set.blank?
# we have to load these one at a time because find_all_by_id gets duplicates during wings transition
resource = Hyrax.query_service.find_by(id: @set[0])
solr_indexer.save(resource: resource)
solr_indexer.connection.commit if(i % 100.0 == 0)
puts "\n\n\n===================== #{i}============ \n\n\n"
rescue
# if anything goes wrong, try to requeue the items
@set.each { |id, _time| queue.connection.zadd(index_error_name + "-twice", Time.now.to_i, id) }
end
end
solr_indexer.connection.commit
queue.connection.zrange(index_error_name + "-twice", 0, -1).size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment