Skip to content

Commit

Permalink
feat: do not call api when document is set to ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Jul 20, 2024
1 parent 73c150a commit 7781ed8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/esse/active_record/callbacks/indexing_on_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class IndexingOnCreate < Callback
def call(model)
record = block_result || model
document = repo.serialize(record)
repo.index.index(document, **options) if document
repo.index.index(document, **options) if document && !document.ignore_on_index?
true
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/esse/active_record/callbacks/indexing_on_destroy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class IndexingOnDestroy < Callback
def call(model)
record = block_result || model
document = repo.serialize(record)
repo.index.delete(document, **options) if document
repo.index.delete(document, **options) if document && !document.ignore_on_delete?
true
rescue Esse::Transport::NotFoundError
true
Expand Down
2 changes: 2 additions & 0 deletions lib/esse/active_record/callbacks/indexing_on_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def call(model)
protected

def update_document(document)
return if document.ignore_on_index?

if update_with == :update
begin
repo.index.update(document, **options)
Expand Down

0 comments on commit 7781ed8

Please sign in to comment.