/iqdb_queries: include full data for each post in api response.
This commit is contained in:
@@ -33,7 +33,13 @@ module Iqdb
|
||||
if resp.is_a?(Net::HTTPSuccess)
|
||||
json = JSON.parse(resp.body)
|
||||
if json.is_a?(Array)
|
||||
@matches = json
|
||||
post_ids = json.map { |match| match["post_id"] }
|
||||
posts = Post.find(post_ids)
|
||||
|
||||
@matches = json.map do |match|
|
||||
post = posts.find { |post| post.id == match["post_id"] }
|
||||
match.with_indifferent_access.merge({ post: post })
|
||||
end
|
||||
else
|
||||
@matches = []
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var html = '';
|
||||
<% if @results.any? %>
|
||||
<% @results.each do |match| %>
|
||||
html += '<%= j PostPresenter.preview(Post.find(match["post_id"]), :tags => "status:any") %>';
|
||||
html += '<%= j PostPresenter.preview(match[:post], :tags => "status:any") %>';
|
||||
<% end %>
|
||||
<% else %>
|
||||
html += '<p>No matches found</p>';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<% if @results.any? %>
|
||||
<h3>Similar</h3>
|
||||
<% @results.each do |match| %>
|
||||
<%= PostPresenter.preview(Post.find(match["post_id"]), :tags => "status:any", :size => true) %>
|
||||
<%= PostPresenter.preview(match[:post], :tags => "status:any", :size => true) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<h3>Similar</h3>
|
||||
|
||||
Reference in New Issue
Block a user