Recommend posts on /posts/show based on voting patterns

This commit is contained in:
Albert Yi
2018-07-18 10:54:03 -07:00
parent 93f52adc81
commit d9a1eeacc9
5 changed files with 59 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
module PostSets
class Similar < PostSets::Post
def initialize(post)
super(tags)
end
def posts
@posts ||= begin
post_ids, scores = RecommenderService.similar(post)
post_ids = post_ids.reject {|x| x == post.id}.slice(0, 5)
Post.find(post_ids)
end
end
def presenter
::Presenters::PostSetPresenters::Post.new(self)
end
end
end