implement post version search report in danbooru (probably broken)

This commit is contained in:
r888888888
2016-09-06 18:02:58 -07:00
parent 1488f82b32
commit 310538dd71
6 changed files with 53 additions and 49 deletions

View File

@@ -0,0 +1,37 @@
module Reports
class PostVersions
attr_reader :tag, :query
def initialize(tag, query_type)
@tag = tag
if query_type == "added"
@query = BigQuery::PostVersion.new.find_added(tag)
else
@query = BigQuery::PostVersion.new.find_removed(tag)
end
end
def mock_version(raw)
PostVersion.new.tap do |x|
x.id = row["f"][0]["v"]
x.post_id = row["f"][1]["v"]
x.updated_at = Time.at(row["f"][2]["v"].to_f)
x.updater_id = row["f"][3]["v"]
x.updater_ip_addr = row["f"][4]["v"]
x.tags = row["f"][5]["v"]
# x.added_tags = row["f"][6]["v"]
# x.removed_tags = row["f"][7]["v"]
x.parent_id = row["f"][8]["v"]
x.rating = row["f"][9]["v"]
x.source = row["f"][10]["v"]
end
end
def post_versions
if query["rows"].present?
query["rows"].map {|x| mock_version(x)}
end
end
end
end

View File

@@ -1,17 +0,0 @@
module Reports
class PostVersionsAdded
attr_reader :tag, :email
def initialize(tag, email)
@tag = tag
@email = email
end
def process!
if tag
json = {"type" => "post_versions_added", "tag" => tag, "email" => email}.to_json
SqsService.new(Danbooru.config.aws_sqs_post_versions_url).send_message(json)
end
end
end
end

View File

@@ -1,17 +0,0 @@
module Reports
class PostVersionsRemoved
attr_reader :tag, :email
def initialize(tag, email)
@tag = tag
@email = email
end
def process!
if tag
json = {"type" => "post_versions_removed", "tag" => tag, "email" => email}.to_json
SqsService.new(Danbooru.config.aws_sqs_post_versions_url).send_message(json)
end
end
end
end