mirror of https://github.com/tootsuite/mastodon
Extract shared tagged statuses method in `FeaturedTag` (#28805)
parent
f0b93ab02f
commit
f866413e72
|
@ -45,7 +45,7 @@ class FeaturedTag < ApplicationRecord
|
|||
end
|
||||
|
||||
def decrement(deleted_status_id)
|
||||
update(statuses_count: [0, statuses_count - 1].max, last_status_at: account.statuses.where(visibility: %i(public unlisted)).tagged_with(tag).where.not(id: deleted_status_id).select(:created_at).first&.created_at)
|
||||
update(statuses_count: [0, statuses_count - 1].max, last_status_at: visible_tagged_account_statuses.where.not(id: deleted_status_id).select(:created_at).first&.created_at)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -55,8 +55,8 @@ class FeaturedTag < ApplicationRecord
|
|||
end
|
||||
|
||||
def reset_data
|
||||
self.statuses_count = account.statuses.where(visibility: %i(public unlisted)).tagged_with(tag).count
|
||||
self.last_status_at = account.statuses.where(visibility: %i(public unlisted)).tagged_with(tag).select(:created_at).first&.created_at
|
||||
self.statuses_count = visible_tagged_account_statuses.count
|
||||
self.last_status_at = visible_tagged_account_statuses.select(:created_at).first&.created_at
|
||||
end
|
||||
|
||||
def validate_featured_tags_limit
|
||||
|
@ -72,4 +72,8 @@ class FeaturedTag < ApplicationRecord
|
|||
def tag_already_featured_for_account?
|
||||
FeaturedTag.by_name(name).exists?(account_id: account_id)
|
||||
end
|
||||
|
||||
def visible_tagged_account_statuses
|
||||
account.statuses.where(visibility: %i(public unlisted)).tagged_with(tag)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue