FEATURE: New plugin API to check if upload is used (#15545)

This commit introduces two new APIs for handling unused uploads, one
can be used to exclude uploads in bulk when the data model allow and
the other one excludes uploads one by one.
This commit is contained in:
Bianca Nenciu
2022-02-16 09:00:30 +02:00
committed by GitHub
parent add4b74e08
commit 5eaf214594
4 changed files with 104 additions and 7 deletions

View File

@ -64,6 +64,30 @@ class Upload < ActiveRecord::Base
)
end
def self.add_unused_callback(&block)
(@unused_callbacks ||= []) << block
end
def self.unused_callbacks
@unused_callbacks
end
def self.reset_unused_callbacks
@unused_callbacks = []
end
def self.add_in_use_callback(&block)
(@in_use_callbacks ||= []) << block
end
def self.in_use_callbacks
@in_use_callbacks
end
def self.reset_in_use_callbacks
@in_use_callbacks = []
end
def self.with_no_non_post_relations
scope = self
.joins(<<~SQL)