* Fix unused role routes being generated * Remove unused JavaScript code * Refactor filters code to be DRYer * Fix `.count == 0` comparisons to `.empty?` in views * Fix filters in views
30 lines
717 B
Ruby
30 lines
717 B
Ruby
# frozen_string_literal: true
|
|
|
|
class InstanceFilter
|
|
KEYS = %i(
|
|
limited
|
|
by_domain
|
|
).freeze
|
|
|
|
attr_reader :params
|
|
|
|
def initialize(params)
|
|
@params = params
|
|
end
|
|
|
|
def results
|
|
if params[:limited].present?
|
|
scope = DomainBlock
|
|
scope = scope.matches_domain(params[:by_domain]) if params[:by_domain].present?
|
|
scope.order(id: :desc)
|
|
elsif params[:allowed].present?
|
|
scope = DomainAllow
|
|
scope = scope.matches_domain(params[:by_domain]) if params[:by_domain].present?
|
|
scope.order(id: :desc)
|
|
else
|
|
scope = Account.remote
|
|
scope = scope.matches_domain(params[:by_domain]) if params[:by_domain].present?
|
|
scope.by_domain_accounts
|
|
end
|
|
end
|
|
end
|