Getting likes for multiple records at once #19

Open
MikeSilvis opened this Issue Sep 19, 2012 · 4 comments

4 participants

@MikeSilvis

Hello,

I have the following:

movies = Movie.all

movies.each do |m|
  puts m.likers(User)
end

and this n*2 queries. Is there anyway to do an includes such that it on Movie.all such that it only queries users once.

@cmer
Owner

It's a bit tricky since we support both Redis and ActiveRecord as a backend. Not sure how this could be implemented properly to be implemented across both?

But indeed, that'd be a great addition. If somebody wants to submit a PR, it would be appreciated.

@vjpr

+1

@samnang

+1, any updates?

@samnang

@MikeSilvis I did a pull request(#31), I'm not sure it helps in your context, but if you need only the number of likers, then it should be good enough for your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment