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

This commit is contained in:
Matt Jankowski authored and GitHub committed 2024-01-18 15:57:10 +00:00
1 parent 2115bc52e4
commit 0b853678a4
3 files changed
+71 -4

No files matched your search

+1
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