toptal / chewy

High-level Elasticsearch Ruby framework based on the official elasticsearch-ruby client
MIT License
1.88k stars 364 forks source link

Run some code after indexing has completed #941

Open DeltaMuzammal opened 4 months ago

DeltaMuzammal commented 4 months ago

I have to broadcast a message right after indexing has completed.

.import! Initiates the indexes and then my broadcast runs even before indexing has completed which results in displaying of old data. How can I make sure to run a broadcast line once indexes has completed in ruby?

Chewy Version 'chewy', '~> 7.3.3'

Chewy.strategy(:urgent) do Index.import!(Table.where(id: reg_ids))

  #I want below line to run after above indexes has completed
  ActionCable.server.broadcast("data_#{user_id}", {body: { user_id: user_id}})

end