rename similar posts to recommended posts, refactor menu on posts/show
This commit is contained in:
20
app/logical/post_sets/recommended.rb
Normal file
20
app/logical/post_sets/recommended.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
module PostSets
|
||||
class Recommended < PostSets::Post
|
||||
def initialize(post)
|
||||
super("")
|
||||
@post = post
|
||||
end
|
||||
|
||||
def posts
|
||||
@posts ||= begin
|
||||
response = RecommenderService.similar(@post)
|
||||
post_ids = response.reject {|x| x[0] == @post.id}.slice(0, 6).map {|x| x[0]}
|
||||
::Post.find(post_ids)
|
||||
end
|
||||
end
|
||||
|
||||
def presenter
|
||||
::PostSetPresenters::Post.new(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user