Skip to content

Commit

Permalink
fix: always load task from repo
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Aug 22, 2024
1 parent 8afce10 commit ac1fd72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
module Esse::AsyncIndexing
module ActiveRecordCallbacks
class LazyUpdateAttribute < Callback
LAZY_ATTR_WORKER = "Esse::AsyncIndexing::Jobs::BulkUpdateLazyAttributeJob"

attr_reader :attribute_name

def initialize(service_name:, attribute_name:, with: nil, **kwargs)
Expand All @@ -14,10 +12,14 @@ def initialize(service_name:, attribute_name:, with: nil, **kwargs)

def call(model)
if (doc_ids = resolve_document_ids(model))
# @TODO Fixme
BackgroundJob.job(service_name, LAZY_ATTR_WORKER)
.with_args(repo.index.name, repo.repo_name, attribute_name.to_s, doc_ids, options)
.push
repo.async_indexing_job_for(:update_lazy_attribute).call(
service: service_name,
repo: repo,
operation: :update_lazy_attribute,
attribute: attribute_name,
ids: doc_ids,
**options
)
end

true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
before do
setup_esse_client!
stub_esse_index(:geos) do
plugin :async_indexing
repository :city do
collection { |**, &block| block.call([{id: 1, name: "City 1"}]) }
document { |hash, **| {_id: hash[:id], name: hash[:name]} }
Expand Down

0 comments on commit ac1fd72

Please sign in to comment.