Replace the old IQDB API client with a new client for the new forked version of IQDB at https://github.com/danbooru/iqdb. Changes: * The /iqdb_queries endpoint now returns `hash` and `signature` fields. The `signature` is the full decoded Haar signature, while the `hash` is a encoded version of the signature. * The /iqdb_queries endpoint no longer returns `width` and `height` fields in the response (these were always 128x128). * We no longer need the IQDBs frontend server, now we talk to the IQDB instance directly. * We no longer send add/remove image commands to IQDB through AWS SQS, now we send them to IQDB directly. They are sent in a delayed job so that if IQDB is down, uploading images is still possible, the add image commands will just get queued up. * Fix a bug where regenerating an image's thumbnails didn't regenerate IQDB, because IQDB silently ignored add image commands when the image already existed in the database.
49 lines
1.0 KiB
Ruby
49 lines
1.0 KiB
Ruby
class MockServicesController < ApplicationController
|
|
skip_forgery_protection
|
|
respond_to :json
|
|
|
|
before_action do
|
|
raise User::PrivilegeError if Rails.env.production?
|
|
end
|
|
|
|
def recommender_recommend
|
|
@data = posts.map { |post| [post.id, rand(0.0..1.0)] }
|
|
render json: @data
|
|
end
|
|
|
|
def recommender_similar
|
|
@data = posts.map { |post| [post.id, rand(0.0..1.0)] }
|
|
render json: @data
|
|
end
|
|
|
|
def reportbooru_missed_searches
|
|
@data = tags.map { |tag| "#{tag.name} #{rand(1.0..1000.0)}" }.join("\n")
|
|
render json: @data
|
|
end
|
|
|
|
def reportbooru_post_searches
|
|
@data = tags.map { |tag| [tag.name, rand(1..1000)] }
|
|
render json: @data
|
|
end
|
|
|
|
def reportbooru_post_views
|
|
@data = posts.map { |post| [post.id, rand(1..1000)] }
|
|
render json: @data
|
|
end
|
|
|
|
def iqdb_query
|
|
@data = posts.map { |post| { post_id: post.id, score: rand(0..100)} }
|
|
render json: @data
|
|
end
|
|
|
|
private
|
|
|
|
def posts(limit = 10)
|
|
Post.last(limit)
|
|
end
|
|
|
|
def tags(limit = 10)
|
|
Tag.order(post_count: :desc).limit(limit)
|
|
end
|
|
end
|