Skip to content
Extraits de code Groupes Projets
Valider 9aad7810 rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

Move visible_posts defaults into a defaults hash, mostly

parent 158401e1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -13,15 +13,20 @@ module Diaspora ...@@ -13,15 +13,20 @@ module Diaspora
end end
def visible_posts(opts = {}) def visible_posts(opts = {})
opts = opts.dup defaults = {
opts[:type] ||= ['StatusMessage', 'Photo'] :type => ['StatusMessage', 'Photo'],
opts[:limit] ||= 15 :order => 'updated_at DESC',
opts[:order] ||= 'updated_at DESC' :limit => 15,
:hidden => false
}
opts = defaults.merge(opts)
order_field = opts[:order].split.first.to_sym order_field = opts[:order].split.first.to_sym
opts[:hidden] ||= false
order_with_table = 'posts.' + opts[:order] order_with_table = 'posts.' + opts[:order]
opts[:max_time] = Time.at(opts[:max_time]) if opts[:max_time].is_a?(Integer) opts[:max_time] = Time.at(opts[:max_time]) if opts[:max_time].is_a?(Integer)
opts[:max_time] ||= Time.now + 1 opts[:max_time] ||= Time.now + 1
select_clause ='DISTINCT posts.id, posts.updated_at AS updated_at, posts.created_at AS created_at' select_clause ='DISTINCT posts.id, posts.updated_at AS updated_at, posts.created_at AS created_at'
posts_from_others = Post.joins(:contacts).where( :post_visibilities => {:hidden => opts[:hidden]}, :contacts => {:user_id => self.id}) posts_from_others = Post.joins(:contacts).where( :post_visibilities => {:hidden => opts[:hidden]}, :contacts => {:user_id => self.id})
......
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