Add admin attachments panel

This commit is contained in:
KMY 2023-02-28 09:16:47 +09:00
parent 15683f583d
commit bd839a8abc
8 changed files with 82 additions and 0 deletions

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
class Form::MediaAttachmentsBatch
include ActiveModel::Model
include Authorization
include AccountableConcern
include Payloadable
attr_accessor :query
def save
end
end

View file

@ -33,6 +33,7 @@ class MediaAttachment < ApplicationRecord
self.inheritance_column = nil
include Attachmentable
include RoutingHelper
enum type: { :image => 0, :gifv => 1, :video => 2, :unknown => 3, :audio => 4 }
enum processing: { :queued => 0, :in_progress => 1, :complete => 2, :failed => 3 }, _prefix: true
@ -208,6 +209,7 @@ class MediaAttachment < ApplicationRecord
scope :local, -> { where(remote_url: '') }
scope :remote, -> { where.not(remote_url: '') }
scope :cached, -> { remote.where.not(file_file_name: nil) }
scope :recently_attachments, -> { attached.order(status_id: 'DESC') }
default_scope { order(id: :asc) }
@ -271,6 +273,10 @@ class MediaAttachment < ApplicationRecord
delay_processing? && attachment_name == :file
end
def url
full_asset_url(file.url(:original))
end
after_commit :enqueue_processing, on: :create
after_commit :reset_parent_cache, on: :update