Add post regenerations

This commit is contained in:
BrokenEagle
2020-11-22 07:08:40 +00:00
committed by evazion
parent e6f2bf1c89
commit 16d6f3bbd5
13 changed files with 234 additions and 12 deletions

View File

@@ -0,0 +1,31 @@
class PostRegeneration < ApplicationRecord
belongs_to :creator, :class_name => "User"
belongs_to :post
validates :category, inclusion: %w[iqdb resizes]
module SearchMethods
def search(params)
q = search_attributes(params, :id, :created_at, :updated_at, :category, :creator, :post)
q.apply_default_order(params)
end
end
extend SearchMethods
def execute_category_action!
if category == "iqdb"
post.update_iqdb_async
elsif category == "resizes"
media_file = MediaFile.open(post.file, frame_data: post.pixiv_ugoira_frame_data)
UploadService::Utils.process_resizes(post, nil, post.id, media_file: media_file)
else
# should never happen
raise Error, "Unknown category: #{category}"
end
end
def self.searchable_includes
[:creator, :post]
end
end