Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Aug 19, 2024
1 parent b700e68 commit e2e3b62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/esse/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def eql?(other, match_lazy_doc_header: false)
if match_lazy_doc_header && other.is_a?(LazyDocumentHeader)
other.eql?(self)
else
other.is_a?(self.class) && (
other.is_a?(Esse::Document) && (
id.to_s == other.id.to_s && type == other.type && routing == other.routing && meta == other.meta && source == other.source
)
end
Expand Down
11 changes: 4 additions & 7 deletions lib/esse/index/documents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,10 @@ def import(*repo_types, context: {}, eager_load_lazy_attributes: false, update_l
collection_context ||= {}
entries = [*batch].map { |entry| repo.serialize(entry, **collection_context) }.compact

if lazy_attrs_to_eager_load
attrs = lazy_attrs_to_eager_load.is_a?(Array) ? lazy_attrs_to_eager_load : repo.lazy_document_attribute_names(lazy_attrs_to_eager_load)
attrs.each do |attr_name|
repo.retrieve_lazy_attribute_values(attr_name, entries).each do |doc_header, value|
doc = entries.find { |d| d.eql?(doc_header, match_lazy_doc_header: true) }
doc&.mutate(attr_name) { value }
end
lazy_attrs_to_eager_load.each do |attr_name|
repo.retrieve_lazy_attribute_values(attr_name, entries).each do |doc_header, value|
doc = entries.find { |d| d.eql?(doc_header, match_lazy_doc_header: true) }
doc&.mutate(attr_name) { value }
end
end

Expand Down

0 comments on commit e2e3b62

Please sign in to comment.