-
Notifications
You must be signed in to change notification settings - Fork 121
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
Accessing read/unread stats via another relationship #77
Comments
I ended up not eager loading the comments at all (as I don't actually use the objects). Instead I'm generating a statistics hash like this:
Results in one query at the start plus several (ultimately cached) queries on the |
Using Your solution looks fine. |
Thanks @ledermann, yep it's working great. Thanks for the help :) |
Just stumbled upon this. @brendon's solution was exactly what we were looking for. It would be a great addition to the README (the whole example?), and explaining that subsequent A bit unnecessary to dig through the issues / finding it by chance :) |
Glad I was able to be of some help @Frexuz :) I'm sure @ledermann would appreciate a PR with the documentation enhancements if you had the time to do it. Would you be keen? :) |
Let me give it a go :) Then @ledermann can adjust |
PR here #98 |
Hi there, I've spent a bit of time trying to figure this out so I thought I'd ask here in case you had any pointers :)
I have a model called
Values
. Avalue
has manycomments
, and the comments readable via your gem.I'm rendering a
document
full ofvalues
so I want to select all thevalues
in adocument
, and also have an additional two columns:comments_count
andunread_comments_count
. This allows me to render the document indicating the comments as efficiently as possible. Right now I'm issuing a query for eachunread_by
call that is causing a performance problem.I've had some success getting an
unread_count
by mergingunread_by()
into the query and forcing aLEFT JOIN
between values and comments. But then it doesn't seem possible to get a count of all of the comments (read and unread) in that same query.Any pointers would be greatly appreciated. :)
The text was updated successfully, but these errors were encountered: