mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-29 14:19:03 +01:00
Add method for media-referencing status in AccountStatusCleanupPolicy
(#31798)
This commit is contained in:
parent
1f13b87567
commit
e6969cf4e4
1 changed files with 9 additions and 1 deletions
|
@ -157,7 +157,7 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def without_media_scope
|
def without_media_scope
|
||||||
Status.where('NOT EXISTS (SELECT 1 FROM media_attachments media WHERE media.status_id = statuses.id)')
|
Status.where.not(status_media_reference_exists)
|
||||||
end
|
end
|
||||||
|
|
||||||
def without_poll_scope
|
def without_poll_scope
|
||||||
|
@ -175,6 +175,14 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
|
||||||
Status.where(account_id: account_id)
|
Status.where(account_id: account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def status_media_reference_exists
|
||||||
|
MediaAttachment
|
||||||
|
.where(MediaAttachment.arel_table[:status_id].eq Status.arel_table[:id])
|
||||||
|
.select(1)
|
||||||
|
.arel
|
||||||
|
.exists
|
||||||
|
end
|
||||||
|
|
||||||
def self_status_reference_exists(model)
|
def self_status_reference_exists(model)
|
||||||
model
|
model
|
||||||
.where(model.arel_table[:account_id].eq Status.arel_table[:account_id])
|
.where(model.arel_table[:account_id].eq Status.arel_table[:account_id])
|
||||||
|
|
Loading…
Reference in a new issue