Code Monkey home page Code Monkey logo

chewy_kiqqer's People

Contributors

averell23 avatar ka8725 avatar xijo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

chewy_kiqqer's Issues

Factory Girl

Hi there,

Firstly great work on the gem(s).

I have a question regarding the use of factory_girl for testing.

Making use of:

product.rb

async_update_index index: 'products#product', backref: :self

and of course

spec_helper.rb

require 'sidekiq'
require 'sidekiq/testing'
require 'fakeredis/rspec'

I cant seem to get objects into the running test Elasticsearch server:9250.

Is this a known use-case? and are there any tips you can provide?

Enhancements: hook into habtm lifecycle + conditional reindexing

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...

Testing index updates with rspec

Hi, I really like your gem but I'm having some trouble writing good rspecs to tests index updates...

The chewy gem itself provides quite nice spec helpers in the form of

 specify { expect { [user1, user2].map(&:save!) }.to update_index(UsersIndex.user).and_reindex(user1) }

But this doesn't work with async index update.

FYI: I'm using Sidekiq inline in rspecs:

#spec_helper.rb
if example.metadata[:sidekiq] == :inline
      Sidekiq::Testing.inline!
end
#users_index_spec.rb
describe UsersIndex, sidekiq: :inline do
    ....
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.