You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.
Hi there, I am finding this gem very useful, thanks for writing it!
In my use case I am indexing the foreign keys of associated habtm records, and wanting to trigger a reindex when a record is added to or removed from the habtm association.
These add and remove events naturally do not trigger after_commit on the subject model.
The habtm after_add: and after_remove: hooks pass the added/removed object into the hook method, so I cannot give them :queue_chewy_jobs because that method takes no parameters.
One idea I had was to wrap queue_chewy_jobs in my own method that stripped the argument passed by the habtm after_add: and after_remove: hooks, so that I could continue to do all the heavy lifting in my async_update_index methods. But this wasn't adequate for my purposes because once within the async_update_index method I have no way of detecting whether or not the habtm changed (I am doing filtering to prevent unnecessary reindex jobs).
So in the end I just call ChewyKiqqer::Worker.perform_async directly from my own hook method, and this works fine.
I don't think there are any easy wins here (this gem is elegant the way it is), but thought to create this issue in order to discover if other folks are interested in reindexing habtm foreign keys when those keys change with chewy_kiqqer. (for example, I find this model useful for sideloading associated records from activerecord after retrieving search results directly from chewy) Maybe over time a better solution will emerge...
The text was updated successfully, but these errors were encountered:
gkop
changed the title
Enhancement: hook into habtm lifecycle
Enhancements: hook into habtm lifecycle + conditional reindexing
Dec 12, 2014
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi there, I am finding this gem very useful, thanks for writing it!
In my use case I am indexing the foreign keys of associated habtm records, and wanting to trigger a reindex when a record is added to or removed from the habtm association.
These add and remove events naturally do not trigger
after_commit
on the subject model.The habtm
after_add:
andafter_remove:
hooks pass the added/removed object into the hook method, so I cannot give them:queue_chewy_jobs
because that method takes no parameters.One idea I had was to wrap
queue_chewy_jobs
in my own method that stripped the argument passed by the habtmafter_add:
andafter_remove:
hooks, so that I could continue to do all the heavy lifting in myasync_update_index
methods. But this wasn't adequate for my purposes because once within theasync_update_index
method I have no way of detecting whether or not the habtm changed (I am doing filtering to prevent unnecessary reindex jobs).So in the end I just call
ChewyKiqqer::Worker.perform_async
directly from my own hook method, and this works fine.I don't think there are any easy wins here (this gem is elegant the way it is), but thought to create this issue in order to discover if other folks are interested in reindexing habtm foreign keys when those keys change with chewy_kiqqer. (for example, I find this model useful for sideloading associated records from activerecord after retrieving search results directly from chewy) Maybe over time a better solution will emerge...
The text was updated successfully, but these errors were encountered: