Add reviewed
and unreviewed
scopes to Reviewable
model concern (#31988)
This commit is contained in:
parent
c922af2737
commit
04a939d640
7 changed files with 33 additions and 23 deletions
|
@ -3,6 +3,11 @@
|
|||
module Reviewable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
scope :reviewed, -> { where.not(reviewed_at: nil) }
|
||||
scope :unreviewed, -> { where(reviewed_at: nil) }
|
||||
end
|
||||
|
||||
def requires_review?
|
||||
reviewed_at.nil?
|
||||
end
|
||||
|
|
|
@ -34,8 +34,6 @@ class PreviewCardProvider < ApplicationRecord
|
|||
|
||||
scope :trendable, -> { where(trendable: true) }
|
||||
scope :not_trendable, -> { where(trendable: false) }
|
||||
scope :reviewed, -> { where.not(reviewed_at: nil) }
|
||||
scope :pending_review, -> { where(reviewed_at: nil) }
|
||||
|
||||
def self.matching_domain(domain)
|
||||
segments = domain.split('.')
|
||||
|
|
|
@ -50,8 +50,6 @@ class Tag < ApplicationRecord
|
|||
validate :validate_name_change, if: -> { !new_record? && name_changed? }
|
||||
validate :validate_display_name_change, if: -> { !new_record? && display_name_changed? }
|
||||
|
||||
scope :reviewed, -> { where.not(reviewed_at: nil) }
|
||||
scope :unreviewed, -> { where(reviewed_at: nil) }
|
||||
scope :pending_review, -> { unreviewed.where.not(requested_review_at: nil) }
|
||||
scope :usable, -> { where(usable: [true, nil]) }
|
||||
scope :not_usable, -> { where(usable: false) }
|
||||
|
@ -127,7 +125,7 @@ class Tag < ApplicationRecord
|
|||
|
||||
query = Tag.matches_name(stripped_term)
|
||||
query = query.merge(Tag.listable) if options[:exclude_unlistable]
|
||||
query = query.merge(matching_name(stripped_term).or(where.not(reviewed_at: nil))) if options[:exclude_unreviewed]
|
||||
query = query.merge(matching_name(stripped_term).or(reviewed)) if options[:exclude_unreviewed]
|
||||
|
||||
query.order(Arel.sql('length(name) ASC, name ASC'))
|
||||
.limit(limit)
|
||||
|
|
|
@ -41,7 +41,7 @@ class Trends::PreviewCardProviderFilter
|
|||
when 'rejected'
|
||||
PreviewCardProvider.not_trendable
|
||||
when 'pending_review'
|
||||
PreviewCardProvider.pending_review
|
||||
PreviewCardProvider.unreviewed
|
||||
else
|
||||
raise Mastodon::InvalidParameterError, "Unknown status: #{value}"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue