Files
danbooru/app/logical/post_sets/artist.rb
evazion 85ae2cda0d optimization: prefer relation.none over relation.where("false")
Using `relation.none` instead of `relation.where("false")` avoids an sql query.
2018-08-23 15:21:51 -05:00

25 lines
509 B
Ruby

module PostSets
class Artist < PostSets::Post
attr_reader :artist
def initialize(artist)
super(artist.name)
@artist = artist
end
def posts
@posts ||= begin
query = ::Post.tag_match(@artist.name).where("true /* PostSets::Artist#posts */").limit(10)
query.each # hack to force rails to eager load
query
end
rescue ::Post::SearchError
::Post.none
end
def presenter
::PostSetPresenters::Post.new(self)
end
end
end