Redesign admin instances area (#9645)
This commit is contained in:
parent
9a38357111
commit
1c6588accc
60 changed files with 159 additions and 531 deletions
|
@ -3,10 +3,23 @@
|
|||
class Instance
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :domain, :accounts_count
|
||||
attr_accessor :domain, :accounts_count, :domain_block
|
||||
|
||||
def initialize(account)
|
||||
@domain = account.domain
|
||||
@accounts_count = account.accounts_count
|
||||
def initialize(resource)
|
||||
@domain = resource.domain
|
||||
@accounts_count = resource.accounts_count
|
||||
@domain_block = resource.is_a?(DomainBlock) ? resource : DomainBlock.find_by(domain: domain)
|
||||
end
|
||||
|
||||
def cached_sample_accounts
|
||||
Rails.cache.fetch("#{cache_key}/sample_accounts", expires_in: 12.hours) { Account.where(domain: domain).searchable.joins(:account_stat).popular.limit(3) }
|
||||
end
|
||||
|
||||
def to_param
|
||||
domain
|
||||
end
|
||||
|
||||
def cache_key
|
||||
domain
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,21 +8,10 @@ class InstanceFilter
|
|||
end
|
||||
|
||||
def results
|
||||
scope = Account.remote.by_domain_accounts
|
||||
params.each do |key, value|
|
||||
scope.merge!(scope_for(key, value)) if value.present?
|
||||
end
|
||||
scope
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def scope_for(key, value)
|
||||
case key.to_s
|
||||
when 'domain_name'
|
||||
Account.matches_domain(value)
|
||||
if params[:limited].present?
|
||||
DomainBlock.order(id: :desc)
|
||||
else
|
||||
raise "Unknown filter: #{key}"
|
||||
Account.remote.by_domain_accounts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue