pass post to comments partial. use sql in raw_visible_posts
This commit is contained in:
parent
99e55c82eb
commit
aa4c20e404
7 changed files with 13 additions and 13 deletions
|
|
@ -27,7 +27,7 @@ class AspectsController < ApplicationController
|
||||||
@selected_contacts = @aspects.map { |aspect| aspect.contacts }.flatten.uniq
|
@selected_contacts = @aspects.map { |aspect| aspect.contacts }.flatten.uniq
|
||||||
@aspect_ids = @aspects.map { |a| a.id }
|
@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(
|
@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)
|
@fakes = PostsFake.new(@posts)
|
||||||
|
|
||||||
@contact_count = current_user.contacts.count
|
@contact_count = current_user.contacts.count
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
%li.comment.posted{:data=>{:guid => comment.id}, :class => ("hidden" if(defined? hidden))}
|
%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
|
.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')
|
= 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)
|
= person_image_link(comment.author)
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@
|
||||||
= image_tag 'icons/spechbubble_2.png', :class => 'more_comments_icon'
|
= image_tag 'icons/spechbubble_2.png', :class => 'more_comments_icon'
|
||||||
%b= comment_toggle(comments.size)
|
%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
|
-if comments.size > 3
|
||||||
.older_comments{:class => ("hidden inactive" if defined?(condensed) && condensed)}
|
.older_comments{:class => ("hidden inactive" if defined?(condensed) && condensed)}
|
||||||
= render :partial => 'comments/comment', :collection => comments[0..-4]
|
= render :partial => 'comments/comment', :collection => comments[0..-4], :locals => {:post => post}
|
||||||
= render :partial => 'comments/comment', :collection => comments[-3, 3]
|
= render :partial => 'comments/comment', :collection => comments[-3, 3], :locals => {:post => post}
|
||||||
-else
|
-else
|
||||||
= render :partial => 'comments/comment', :collection => comments
|
= render :partial => 'comments/comment', :collection => comments, :locals => {:post => post}
|
||||||
|
|
||||||
- unless @commenting_disabled
|
- unless @commenting_disabled
|
||||||
%li.comment.show
|
%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}}
|
%div{:data=>{:guid=>@parent.id}}
|
||||||
.likes_container
|
.likes_container
|
||||||
= render "likes/likes", :post_id => @parent.id, :likes => @parent.likes, :dislikes => @parent.dislikes
|
= 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
|
/.likes_container
|
||||||
/ = render "likes/likes", :post_id => post.id, :likes => post.likes, :dislikes => post.dislikes, :current_user => current_user
|
/ = 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')
|
= t('_comments')
|
||||||
#status_message_stream.stream.show
|
#status_message_stream.stream.show
|
||||||
%div{:data=>{:guid=>@status_message.id}}
|
%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 = {})
|
def raw_visible_posts(opts = {})
|
||||||
opts[:type] ||= ['StatusMessage', 'Photo']
|
opts[:type] ||= ['StatusMessage', 'Photo']
|
||||||
opts[:limit] ||= 20
|
opts[:limit] ||= 20
|
||||||
opts[:order] ||= 'created_at DESC'
|
opts[:order] ||= 'updated_at DESC'
|
||||||
opts[:order] = '`posts`.' + opts[:order]
|
opts[:order] = '`posts`.' + opts[:order]
|
||||||
|
|
||||||
posts_from_others = Post.joins(:contacts).where(:contacts => {:user_id => self.id})
|
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]})
|
posts_from_self = posts_from_self.where(:aspects => {:id => opts[:by_members_of]})
|
||||||
end
|
end
|
||||||
|
|
||||||
post_ids = posts_from_others.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 += posts_from_self.select('posts.id').limit(opts[:limit]).order(opts[:order]).map{|p| p.id}
|
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])
|
Post.where(:id => post_ids, :pending => false, :type => opts[:type]).select('DISTINCT `posts`.*').limit(opts[:limit])
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue