mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 16:59:41 +00:00
Extract by_domain_length scope in DomainNormalizable concern (#29517)
This commit is contained in:
@@ -5,6 +5,18 @@ module DomainNormalizable
|
||||
|
||||
included do
|
||||
before_validation :normalize_domain
|
||||
|
||||
scope :by_domain_length, -> { order(domain_char_length.desc) }
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def domain_char_length
|
||||
Arel.sql(
|
||||
<<~SQL.squish
|
||||
CHAR_LENGTH(domain)
|
||||
SQL
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user