reduce the number of ruby objects instantiated in posts_from
This commit is contained in:
parent
5b0da52e0a
commit
2487db3257
1 changed files with 3 additions and 2 deletions
|
|
@ -86,9 +86,10 @@ module Diaspora
|
|||
p = Post.arel_table
|
||||
post_ids = []
|
||||
if contact = self.contact_for(person)
|
||||
post_ids = contact.post_visibilities.select('post_visibilities.post_id').map{|p| p.post_id}
|
||||
post_ids = Post.connection.execute(contact.post_visibilities.select('post_visibilities.post_id').to_sql).map{|r| r.first}
|
||||
end
|
||||
post_ids += person.posts.where(:public => true).select('posts.id').map{|p| p.id}
|
||||
post_ids += Post.connection.execute(person.posts.where(:public => true).select('posts.id').to_sql).map{|r| r.first}
|
||||
|
||||
Post.where(:id => post_ids, :pending => false).select('DISTINCT `posts`.*').order("posts.created_at DESC")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue