mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-18 04:43:24 +00:00
Add Instance class to list admin records (#3443)
This commit is contained in:
parent
b25e42a77f
commit
a132332b86
|
@ -3,13 +3,18 @@
|
||||||
module Admin
|
module Admin
|
||||||
class InstancesController < BaseController
|
class InstancesController < BaseController
|
||||||
def index
|
def index
|
||||||
@instances = ordered_instances.page(params[:page])
|
@instances = ordered_instances
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def paginated_instances
|
||||||
|
Account.remote.by_domain_accounts.page(params[:page])
|
||||||
|
end
|
||||||
|
helper_method :paginated_instances
|
||||||
|
|
||||||
def ordered_instances
|
def ordered_instances
|
||||||
Account.remote.by_domain_accounts
|
paginated_instances.map { |account| Instance.new(account) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
12
app/models/instance.rb
Normal file
12
app/models/instance.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Instance
|
||||||
|
include ActiveModel::Model
|
||||||
|
|
||||||
|
attr_accessor :domain, :accounts_count
|
||||||
|
|
||||||
|
def initialize(account)
|
||||||
|
@domain = account.domain
|
||||||
|
@accounts_count = account.accounts_count
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,6 +7,6 @@
|
||||||
%th= t('admin.instances.domain_name')
|
%th= t('admin.instances.domain_name')
|
||||||
%th= t('admin.instances.account_count')
|
%th= t('admin.instances.account_count')
|
||||||
%tbody
|
%tbody
|
||||||
= render partial: 'instance', collection: @instances
|
= render @instances
|
||||||
|
|
||||||
= paginate @instances
|
= paginate paginated_instances
|
||||||
|
|
Loading…
Reference in a new issue