-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
README enqueuing instructions are... a bit confusing #102
Comments
As an aside, I know you have a more complete example above that handles deleting better, mostly I am confused as to why a sidekiq example that could never work is included. There should also probably be a helper to get the computed Algolia index name from the model class! |
Found it! This might be a better snippet for a general purpose algolia worker: # don't actually need removed parameter here, now
def self.trigger_algolia_update record, removed
AlgoliaSyncWorker.perform_async 'Contact', record.id
end class AlgoliaSyncWorker
include Sidekiq::Worker
def perform model_name, id
klass = model_name.constantize
record = klass.find_by_id id
if record
record.index!
else
Algolia::Index.new(klass.index_name).delete_object(id)
end
end
end |
Yes OK, that makes sense. Do you want to submit a PR @vincentwoo? |
no |
We'll tackle it while fixing #75 |
For example, read the snippet for explaining how to trigger sidekiq queueing:
If a record is deleted, presumably the worker will be enqueued with the tuple
id
,true
. At some later point, the worker will attempt to runContact.find id
and immediately throw an exception because that id will not be present in the table. Even if it didn't, somehow, what would be returned? Probablynil
, since the record is gone. How then can you callremove_from_index!
onc
?The text was updated successfully, but these errors were encountered: