Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Using Nested Selects for Performance in Rails. Parent comment
I wish if we could do something like:
has_one :approved_comments_count, -> { select(:post_id, 'COUNT(comments.post_id) as comment_count').group(:post_id) }, class_name: 'Comment'
and
posts.includes(:approved_comments_count).map(&:comment_count)
There are no comments on this comment yet.
I wish if we could do something like:
has_one :approved_comments_count, -> { select(:post_id, 'COUNT(comments.post_id) as comment_count').group(:post_id) }, class_name: 'Comment'
and
posts.includes(:approved_comments_count).map(&:comment_count)