diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index f468dacf6..842bd73d7 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -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', :page => params[:page]).includes( - :comments, :mentions, :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 => "posts.#{session[:sort_order]} DESC") @fakes = PostsFake.new(@posts) @contact_count = current_user.contacts.count diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index c1cb79daa..62628e9c1 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -33,7 +33,7 @@ module Diaspora post_ids = Post.connection.execute(posts_from_others.select('posts.id').limit(opts[:limit]).order(order_with_table).to_sql).map{|r| r.first} post_ids += Post.connection.execute(posts_from_self.select('posts.id').limit(opts[:limit]).order(order_with_table).to_sql).map{|r| r.first} - Post.where(:id => post_ids, :pending => false, :type => opts[:type]).select('DISTINCT `posts`.*').limit(opts[:limit]).order(opts[:order]) + Post.where(:id => post_ids, :pending => false, :type => opts[:type]).select('DISTINCT `posts`.*').limit(opts[:limit]).order(order_with_table) end def visible_photos diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index a9b17968b..ea60c9006 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -133,7 +133,7 @@ describe User do context 'with many posts' do before do bob.move_contact(eve.person, bob.aspects.first, bob.aspects.create(:name => 'new aspect')) - (1..18).each do |n| + (1..25).each do |n| [alice, bob, eve].each do |u| post = u.post :status_message, :text => "#{u.username} - #{n}", :to => u.aspects.first.id post.created_at = post.created_at - n*10*u.id