Skip to content

Commit

Permalink
Move hardcoded { softCommit: true } to class constant
Browse files Browse the repository at this point in the history
  • Loading branch information
mbklein committed Nov 17, 2017
1 parent ea0095a commit d6ee10e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/valkyrie/persistence/solr/repository.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
module Valkyrie::Persistence::Solr
class Repository
COMMIT_PARAMS = { softCommit: true }.freeze

attr_reader :resources, :connection, :resource_factory
def initialize(resources:, connection:, resource_factory:)
@resources = resources
Expand All @@ -13,14 +15,14 @@ def persist
generate_id(resource) if resource.id.blank?
solr_document(resource)
end
connection.add documents, params: { softCommit: true }
connection.add documents, params: COMMIT_PARAMS
documents.map do |document|
resource_factory.to_resource(object: document.stringify_keys)
end
end

def delete
connection.delete_by_id resources.map { |resource| resource.id.to_s }, params: { softCommit: true }
connection.delete_by_id resources.map { |resource| resource.id.to_s }, params: COMMIT_PARAMS
resources
end

Expand Down

0 comments on commit d6ee10e

Please sign in to comment.