fix for iqdb queries

This commit is contained in:
Albert Yi
2016-12-02 13:06:34 -08:00
parent a358247c1c
commit 8e5331d234
3 changed files with 4 additions and 4 deletions

View File

@@ -30,6 +30,6 @@ protected
@download = Iqdb::Download.new(@post.complete_preview_file_url) @download = Iqdb::Download.new(@post.complete_preview_file_url)
@download.find_similar @download.find_similar
@results = @download.matches @results = @download.matches
render :layout => false, :action => "create_by_url" render :layout => false, :action => "create_by_post"
end end
end end

View File

@@ -33,9 +33,9 @@ module Iqdb
if resp.is_a?(Net::HTTPSuccess) if resp.is_a?(Net::HTTPSuccess)
json = JSON.parse(resp.body) json = JSON.parse(resp.body)
if json.is_a?(Array) if json.is_a?(Array)
json @matches = json
else else
[] @matches = []
end end
else else
raise "HTTP error code: #{resp.code} #{resp.message}" raise "HTTP error code: #{resp.code} #{resp.message}"

View File

@@ -1,7 +1,7 @@
var html = ''; var html = '';
<% if @results.any? %> <% if @results.any? %>
<% @results.each do |match| %> <% @results.each do |match| %>
html += '<%= j PostPresenter.preview(Post.find(match.post_id), :tags => "status:any") %>'; html += '<%= j PostPresenter.preview(Post.find(match["post_id"]), :tags => "status:any") %>';
<% end %> <% end %>
<% else %> <% else %>
html += '<p>No matches found</p>'; html += '<p>No matches found</p>';