Skip to content
Extraits de code Groupes Projets
Valider 6df652a5 rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

Limit posts in raw_visible_posts

parent 2f473cad
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -12,6 +12,7 @@ module Diaspora ...@@ -12,6 +12,7 @@ module Diaspora
def raw_visible_posts(opts = {}) def raw_visible_posts(opts = {})
opts[:type] ||= ['StatusMessage', 'Photo'] opts[:type] ||= ['StatusMessage', 'Photo']
opts[:limit] ||= 20
posts_from_others = Post.joins(:contacts).where(:contacts => {:user_id => self.id}) posts_from_others = Post.joins(:contacts).where(:contacts => {:user_id => self.id})
posts_from_self = self.person.posts.joins(:aspect_visibilities => :aspect).where(:aspects => {:user_id => self.id}) posts_from_self = self.person.posts.joins(:aspect_visibilities => :aspect).where(:aspects => {:user_id => self.id})
...@@ -22,10 +23,10 @@ module Diaspora ...@@ -22,10 +23,10 @@ module Diaspora
posts_from_self = posts_from_self.where(:aspects => {:id => opts[:by_members_of]}) posts_from_self = posts_from_self.where(:aspects => {:id => opts[:by_members_of]})
end end
post_ids = posts_from_others.select('posts.id').map{|p| p.id} post_ids = posts_from_others.select('posts.id').limit(opts[:limit]).map{|p| p.id}
post_ids += posts_from_self.select('posts.id').map{|p| p.id} post_ids += posts_from_self.select('posts.id').limit(opts[:limit]).map{|p| p.id}
Post.where(:id => post_ids, :pending => false, :type => opts[:type]).select('DISTINCT `posts`.*') Post.where(:id => post_ids, :pending => false, :type => opts[:type]).select('DISTINCT `posts`.*').limit(opts[:limit])
end end
def visible_photos def visible_photos
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter