Extract by_domain_length
scope in DomainNormalizable
concern (#29517)
This commit is contained in:
parent
5b60d4b696
commit
d4ed7e466c
4 changed files with 15 additions and 3 deletions
|
@ -54,6 +54,6 @@ class PreviewCardProvider < ApplicationRecord
|
|||
|
||||
def self.matching_domain(domain)
|
||||
segments = domain.split('.')
|
||||
where(domain: segments.map.with_index { |_, i| segments[i..].join('.') }).order(Arel.sql('char_length(domain) desc')).first
|
||||
where(domain: segments.map.with_index { |_, i| segments[i..].join('.') }).by_domain_length.first
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue