Skip to content

Commit

Permalink
Modernise query.
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Nov 20, 2014
1 parent 83507f2 commit 9c4d481
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/models/pool.rb
Expand Up @@ -108,12 +108,12 @@ def transfer_post_to_parent(post_id, parent_id)
def get_sample
# By preference, pick the first post (by sequence) in the pool that isn't hidden from
# the index.
PoolPost.find(:all, :order => "posts.is_shown_in_index DESC, nat_sort(pools_posts.sequence), pools_posts.post_id",
:joins => "JOIN posts ON posts.id = pools_posts.post_id",
:conditions => ["pool_id = ? AND posts.status = 'active' AND pools_posts.active", id]).each do |pool_post|
return pool_post.post if pool_post.post.can_be_seen_by?(Thread.current["danbooru-user"])
PoolPost.joins(:post)
.where(:pool_id => id, :active => true, :posts => { :status => "active" })
.order("posts.is_shown_in_index DESC, NAT_SORT(pools_posts.sequence), pools_posts.post_id")
.each do |pool_post|
return pool_post.post if pool_post.post.can_be_seen_by?(Thread.current["danbooru-user"])
end
return rescue nil
end

def can_change_is_public?(user)
Expand Down

0 comments on commit 9c4d481

Please sign in to comment.