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

pass post to comments partial. use sql in raw_visible_posts

parent 99e55c82
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -27,7 +27,7 @@ class AspectsController < ApplicationController
@selected_contacts = @aspects.map { |aspect| aspect.contacts }.flatten.uniq
@aspect_ids = @aspects.map { |a| a.id }
@posts = current_user.raw_visible_posts(:by_members_of => @aspect_ids, :type => 'StatusMessage', :order => session[:sort_order] + ' DESC').includes(
:comments, :likes, :dislikes).paginate(:page => params[:page], :per_page => 15, :order => session[:sort_order] + ' DESC')
:comments, :mentions, :likes, :dislikes).paginate(:page => params[:page], :per_page => 15, :order => session[:sort_order] + ' DESC')
@fakes = PostsFake.new(@posts)
@contact_count = current_user.contacts.count
......
......@@ -3,7 +3,7 @@
-# the COPYRIGHT file.
%li.comment.posted{:data=>{:guid => comment.id}, :class => ("hidden" if(defined? hidden))}
- if current_user && (current_user.owns?(comment) || current_user.owns?(comment.post))
- if current_user && (current_user.owns?(comment) || current_user.owns?(post))
.right.controls
= link_to image_tag('deletelabel.png'), comment_path(comment), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete comment_delete", :title => t('delete')
= person_image_link(comment.author)
......
......@@ -10,14 +10,14 @@
= image_tag 'icons/spechbubble_2.png', :class => 'more_comments_icon'
%b= comment_toggle(comments.size)
%ul.comments{:id => post_id, :class => ("hidden" if comments.size == 0 && !defined?(force_open) && !is_expanded)}
%ul.comments{:id => post.id, :class => ("hidden" if comments.size == 0 && !defined?(force_open) && !is_expanded)}
-if comments.size > 3
.older_comments{:class => ("hidden inactive" if defined?(condensed) && condensed)}
= render :partial => 'comments/comment', :collection => comments[0..-4]
= render :partial => 'comments/comment', :collection => comments[-3, 3]
= render :partial => 'comments/comment', :collection => comments[0..-4], :locals => {:post => post}
= render :partial => 'comments/comment', :collection => comments[-3, 3], :locals => {:post => post}
-else
= render :partial => 'comments/comment', :collection => comments
= render :partial => 'comments/comment', :collection => comments, :locals => {:post => post}
- unless @commenting_disabled
%li.comment.show
= new_comment_form(post_id, current_user)
= new_comment_form(post.id, current_user)
......@@ -76,4 +76,4 @@
%div{:data=>{:guid=>@parent.id}}
.likes_container
= render "likes/likes", :post_id => @parent.id, :likes => @parent.likes, :dislikes => @parent.dislikes
= render "comments/comments", :post_id => @parent.id, :comments => @parent.comments, :always_expanded => true
= render "comments/comments", :post => @parent, :comments => @parent.comments, :always_expanded => true
......@@ -44,4 +44,4 @@
/.likes_container
/ = render "likes/likes", :post_id => post.id, :likes => post.likes, :dislikes => post.dislikes, :current_user => current_user
= render "comments/comments", :post_id => post.id, :comments => post.comments, :current_user => current_user, :condensed => true, :commenting_disabled => (defined?(@commenting_disabled) && @commenting_disabled)
= render "comments/comments", :post => post, :comments => post.comments, :current_user => current_user, :condensed => true, :commenting_disabled => (defined?(@commenting_disabled) && @commenting_disabled)
......@@ -29,4 +29,4 @@
= t('_comments')
#status_message_stream.stream.show
%div{:data=>{:guid=>@status_message.id}}
= render "comments/comments", :post_id => @status_message.id, :comments => @status_message.comments, :always_expanded => true
= render "comments/comments", :post => @status_message, :comments => @status_message.comments, :always_expanded => true
......@@ -13,7 +13,7 @@ module Diaspora
def raw_visible_posts(opts = {})
opts[:type] ||= ['StatusMessage', 'Photo']
opts[:limit] ||= 20
opts[:order] ||= 'created_at DESC'
opts[:order] ||= 'updated_at DESC'
opts[:order] = '`posts`.' + opts[:order]
posts_from_others = Post.joins(:contacts).where(:contacts => {:user_id => self.id})
......@@ -25,8 +25,8 @@ module Diaspora
posts_from_self = posts_from_self.where(:aspects => {:id => opts[:by_members_of]})
end
post_ids = posts_from_others.select('posts.id').limit(opts[:limit]).order(opts[:order]).map{|p| p.id}
post_ids += posts_from_self.select('posts.id').limit(opts[:limit]).order(opts[:order]).map{|p| p.id}
post_ids = Post.connection.execute(posts_from_others.select('posts.id').limit(opts[:limit]).order(opts[:order]).to_sql).map{|r| r.first}
post_ids += Post.connection.execute(posts_from_self.select('posts.id').limit(opts[:limit]).order(opts[:order]).to_sql).map{|r| r.first}
Post.where(:id => post_ids, :pending => false, :type => opts[:type]).select('DISTINCT `posts`.*').limit(opts[:limit])
end
......
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