fixes #2130
This commit is contained in:
@@ -4,7 +4,6 @@ module Iqdb
|
||||
Post.find_each do |post|
|
||||
IO.popen("iqdb command #{Danbooru.config.iqdb_file}", "w+") do |io|
|
||||
if File.exists?(post.preview_file_path)
|
||||
puts post.id
|
||||
hex = post.id.to_s(16)
|
||||
io.puts "add 0 #{hex}:#{post.preview_file_path}"
|
||||
end
|
||||
|
||||
@@ -2,6 +2,7 @@ module Iqdb
|
||||
module Responses
|
||||
class Collection
|
||||
attr_reader :responses
|
||||
delegate :each, :empty?, :any?, :to => :matches
|
||||
|
||||
def initialize(response_string)
|
||||
@responses = response_string.split(/\n/).map do |string|
|
||||
@@ -13,10 +14,6 @@ module Iqdb
|
||||
@matches ||= responses.select {|x| x.is_a?(Iqdb::Responses::Response_200) && x.score >= 90}
|
||||
end
|
||||
|
||||
def empty?
|
||||
matches.empty?
|
||||
end
|
||||
|
||||
def errored?
|
||||
errors.any?
|
||||
end
|
||||
|
||||
@@ -7,6 +7,10 @@ module Iqdb
|
||||
|
||||
attr_reader :hostname, :port, :socket
|
||||
|
||||
def self.default
|
||||
new(*Danbooru.config.iqdb_hostname_and_port)
|
||||
end
|
||||
|
||||
def initialize(hostname, port)
|
||||
@hostname = hostname
|
||||
@port = port
|
||||
@@ -45,6 +49,15 @@ module Iqdb
|
||||
end
|
||||
end
|
||||
|
||||
def similar(post_id, results, flags = FLAG_DISCARD_COMMON_COEFFS)
|
||||
request do
|
||||
hex_id = post_id.to_s(16)
|
||||
socket.puts "sim 0 #{flags} #{results} #{hex_id}"
|
||||
socket.puts "done"
|
||||
responses = Responses::Collection.new(@socket.read)
|
||||
end
|
||||
end
|
||||
|
||||
def query(results, filename, flags = FLAG_DISCARD_COMMON_COEFFS)
|
||||
request do
|
||||
socket.puts "query 0 #{flags} #{results} #{filename}"
|
||||
|
||||
Reference in New Issue
Block a user