Take out limit hack, pass offset through instead
This commit is contained in:
parent
03e37d2186
commit
fddd252aee
1 changed files with 4 additions and 4 deletions
|
|
@ -19,7 +19,7 @@ module Diaspora
|
|||
opts[:order] ||= 'updated_at DESC'
|
||||
opts[:hidden] ||= false
|
||||
order_with_table = 'posts.' + opts[:order]
|
||||
opts[:limit] = opts[:limit].to_i * opts[:page].to_i if opts[:page]
|
||||
opts[:offset] = opts[:page] ? opts[:limit] * opts[:page] - 1 : 0
|
||||
select_clause ='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})
|
||||
|
|
@ -31,13 +31,13 @@ module Diaspora
|
|||
posts_from_self = posts_from_self.joins(:aspect_visibilities).where(:aspect_visibilities => {:aspect_id => opts[:by_members_of]})
|
||||
end
|
||||
|
||||
posts_from_others = posts_from_others.select(select_clause).limit(opts[:limit]).order(order_with_table)
|
||||
posts_from_self = posts_from_self.select(select_clause).limit(opts[:limit]).order(order_with_table)
|
||||
posts_from_others = posts_from_others.select(select_clause).limit(opts[:limit]).offset(opts[:offset]).order(order_with_table)
|
||||
posts_from_self = posts_from_self.select(select_clause).limit(opts[:limit]).offset(opts[:offset]).order(order_with_table)
|
||||
|
||||
all_posts = "(#{posts_from_others.to_sql}) UNION (#{posts_from_self.to_sql}) ORDER BY #{opts[:order]} LIMIT #{opts[:limit]}"
|
||||
post_ids = Post.connection.execute(all_posts).map{|r| r.first}
|
||||
|
||||
Post.where(:id => post_ids, :pending => false, :type => opts[:type]).select('DISTINCT posts.*').limit(opts[:limit]).order(order_with_table)
|
||||
Post.where(:id => post_ids, :pending => false, :type => opts[:type]).select('DISTINCT posts.*').limit(opts[:limit]).order(order_with_table).offset(opts[:offset])
|
||||
end
|
||||
|
||||
def visible_photos
|
||||
|
|
|
|||
Loading…
Reference in a new issue