0
0
Fork 0

Add coverage for api/v1/peers/search endpoint and extract controller query to Instance scope (#28796)

This commit is contained in:
Matt Jankowski 2024-01-18 10:57:10 -05:00 committed by GitHub
parent 2115bc52e4
commit 0b853678a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 71 additions and 4 deletions

View file

@ -23,6 +23,7 @@ class Instance < ApplicationRecord
scope :searchable, -> { where.not(domain: DomainBlock.select(:domain)) }
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
scope :domain_starts_with, ->(value) { where(arel_table[:domain].matches("#{sanitize_sql_like(value)}%", false, true)) }
scope :by_domain_and_subdomains, ->(domain) { where("reverse('.' || domain) LIKE reverse(?)", "%.#{domain}") }
def self.refresh