fix upload tags report
This commit is contained in:
@@ -22,6 +22,5 @@ class ReportsController < ApplicationController
|
|||||||
def upload_tags
|
def upload_tags
|
||||||
@user = User.find(params[:user_id])
|
@user = User.find(params[:user_id])
|
||||||
@upload_reports = Reports::UploadTags.for_user(params[:user_id]).order("id desc").paginate(params[:page], :limit => params[:limit])
|
@upload_reports = Reports::UploadTags.for_user(params[:user_id]).order("id desc").paginate(params[:page], :limit => params[:limit])
|
||||||
respond_with(@upload_reports)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
69
app/logical/reports/upload_tags.rb
Normal file
69
app/logical/reports/upload_tags.rb
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
module Reports
|
||||||
|
class UploadTags < ::Post
|
||||||
|
|
||||||
|
def readonly?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
module ApiMethods
|
||||||
|
|
||||||
|
def as_json(options = {})
|
||||||
|
options ||= {}
|
||||||
|
options[:only] ||= [:id]
|
||||||
|
super(options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_xml(options = {}, &block)
|
||||||
|
options ||= {}
|
||||||
|
options[:only] ||= [:id, :uploader_id]
|
||||||
|
super(options, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def method_attributes
|
||||||
|
[:uploader_tags, :added_tags, :removed_tags]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
include ApiMethods
|
||||||
|
|
||||||
|
def uploader_tags_array
|
||||||
|
@uploader_tags ||= begin
|
||||||
|
added_tags = []
|
||||||
|
PostArchive.where(post_id: id, updater_id: uploader_id).each do |version|
|
||||||
|
added_tags += version.changes[:added_tags]
|
||||||
|
end
|
||||||
|
added_tags.uniq.sort
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_tags_array
|
||||||
|
latest_tags = tag_array
|
||||||
|
latest_tags << "rating:#{rating}" if rating.present?
|
||||||
|
latest_tags << "parent:#{parent_id}" if parent_id.present?
|
||||||
|
latest_tags << "source:#{source}" if source.present?
|
||||||
|
latest_tags
|
||||||
|
end
|
||||||
|
|
||||||
|
def added_tags_array
|
||||||
|
current_tags_array - uploader_tags_array
|
||||||
|
end
|
||||||
|
|
||||||
|
def removed_tags_array
|
||||||
|
uploader_tags_array - current_tags_array
|
||||||
|
end
|
||||||
|
|
||||||
|
def uploader_tags
|
||||||
|
uploader_tags_array.join(' ')
|
||||||
|
end
|
||||||
|
|
||||||
|
def added_tags
|
||||||
|
added_tags_array.join(' ')
|
||||||
|
end
|
||||||
|
|
||||||
|
def removed_tags
|
||||||
|
removed_tags_array.join(' ')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -12,7 +12,7 @@ class AmazonBackup < ActiveRecord::Base
|
|||||||
first.update_column(:last_id, new_id)
|
first.update_column(:last_id, new_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.restore_from_glacier(min_id, max_id)
|
def self.restore_from_glacier(min_id = 1_431_595, max_id = 2_000_000)
|
||||||
credentials = Aws::Credentials.new(Danbooru.config.aws_access_key_id, Danbooru.config.aws_secret_access_key)
|
credentials = Aws::Credentials.new(Danbooru.config.aws_access_key_id, Danbooru.config.aws_secret_access_key)
|
||||||
Aws.config.update({
|
Aws.config.update({
|
||||||
region: "us-east-1",
|
region: "us-east-1",
|
||||||
@@ -73,7 +73,7 @@ class AmazonBackup < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.copy_to_standard(min_id, max_id)
|
def self.copy_to_standard(min_id = 1_191_247, max_id = 2_000_000)
|
||||||
credentials = Aws::Credentials.new(Danbooru.config.aws_access_key_id, Danbooru.config.aws_secret_access_key)
|
credentials = Aws::Credentials.new(Danbooru.config.aws_access_key_id, Danbooru.config.aws_secret_access_key)
|
||||||
Aws.config.update({
|
Aws.config.update({
|
||||||
region: "us-east-1",
|
region: "us-east-1",
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
class UploadTagsReport < Post
|
|
||||||
|
|
||||||
def readonly?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
module ApiMethods
|
|
||||||
|
|
||||||
def as_json(options = {})
|
|
||||||
options ||= {}
|
|
||||||
options[:only] ||= [:id]
|
|
||||||
super(options)
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_xml(options = {}, &block)
|
|
||||||
options ||= {}
|
|
||||||
options[:only] ||= [:id, :uploader_id]
|
|
||||||
super(options, &block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def method_attributes
|
|
||||||
[:uploader_tags, :added_tags, :removed_tags]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
include ApiMethods
|
|
||||||
|
|
||||||
def uploader_tags_array
|
|
||||||
@uploader_tags ||= begin
|
|
||||||
added_tags = []
|
|
||||||
PostArchive.where(post_id: id, updater_id: uploader_id).each do |version|
|
|
||||||
added_tags += version.changes[:added_tags]
|
|
||||||
end
|
|
||||||
added_tags.uniq.sort
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def current_tags_array
|
|
||||||
latest_tags = tag_array
|
|
||||||
latest_tags << "rating:#{rating}" if rating.present?
|
|
||||||
latest_tags << "parent:#{parent_id}" if parent_id.present?
|
|
||||||
latest_tags << "source:#{source}" if source.present?
|
|
||||||
latest_tags
|
|
||||||
end
|
|
||||||
|
|
||||||
def added_tags_array
|
|
||||||
current_tags_array - uploader_tags_array
|
|
||||||
end
|
|
||||||
|
|
||||||
def removed_tags_array
|
|
||||||
uploader_tags_array - current_tags_array
|
|
||||||
end
|
|
||||||
|
|
||||||
def uploader_tags
|
|
||||||
uploader_tags_array.join(' ')
|
|
||||||
end
|
|
||||||
|
|
||||||
def added_tags
|
|
||||||
added_tags_array.join(' ')
|
|
||||||
end
|
|
||||||
|
|
||||||
def removed_tags
|
|
||||||
removed_tags_array.join(' ')
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user