bug fixes + tests

This commit is contained in:
Albert Yi
2018-07-20 12:30:29 -07:00
parent d9a1eeacc9
commit 75162d3d8b
4 changed files with 30 additions and 9 deletions

View File

@@ -324,6 +324,10 @@ div#c-posts {
font-weight: bold;
}
.similar-posts {
margin-top: 1em;
}
#add-fav-button, #remove-fav-button {
margin-top: 1em;
}

View File

@@ -1,19 +1,20 @@
module PostSets
class Similar < PostSets::Post
def initialize(post)
super(tags)
super("")
@post = post
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)
response = RecommenderService.similar(@post)
post_ids = response.reject {|x| x[0] == @post.id}.slice(0, 5).map {|x| x[0]}
::Post.find(post_ids)
end
end
def presenter
::Presenters::PostSetPresenters::Post.new(self)
::PostSetPresenters::Post.new(self)
end
end
end

View File

@@ -1,7 +1,7 @@
<div class="recent-posts">
<p>You might also like:</p>
<div class="similar-posts">
<p><em>You might also like:</em></p>
<div>
<section>
<%= PostSets::Similar.new(post).presenter.post_previews_html(self) %>
</div>
</section>
</div>