0
0
Fork 0

Use Arel in_order_of method to generate CASE for DomainBlock.by_severity (#28617)

This commit is contained in:
Matt Jankowski 2024-01-08 06:15:36 -05:00 committed by GitHub
parent 57f49c8191
commit 202951e6d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -31,7 +31,7 @@ class DomainBlock < ApplicationRecord
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
scope :with_user_facing_limitations, -> { where(severity: [:silence, :suspend]) }
scope :with_limitations, -> { where(severity: [:silence, :suspend]).or(where(reject_media: true)) }
scope :by_severity, -> { order(Arel.sql('(CASE severity WHEN 0 THEN 1 WHEN 1 THEN 2 WHEN 2 THEN 0 END), domain')) }
scope :by_severity, -> { in_order_of(:severity, %w(noop silence suspend)).order(:domain) }
def to_log_human_identifier
domain