diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin/instances_controller.rb | 9 | ||||
-rw-r--r-- | app/models/instance.rb | 12 | ||||
-rw-r--r-- | app/views/admin/instances/index.html.haml | 4 |
3 files changed, 21 insertions, 4 deletions
diff --git a/app/controllers/admin/instances_controller.rb b/app/controllers/admin/instances_controller.rb index b8f170ec2..ac93248a8 100644 --- a/app/controllers/admin/instances_controller.rb +++ b/app/controllers/admin/instances_controller.rb @@ -3,13 +3,18 @@ module Admin class InstancesController < BaseController def index - @instances = ordered_instances.page(params[:page]) + @instances = ordered_instances end private + def paginated_instances + Account.remote.by_domain_accounts.page(params[:page]) + end + helper_method :paginated_instances + def ordered_instances - Account.remote.by_domain_accounts + paginated_instances.map { |account| Instance.new(account) } end end end diff --git a/app/models/instance.rb b/app/models/instance.rb new file mode 100644 index 000000000..6d5c9c2ab --- /dev/null +++ b/app/models/instance.rb @@ -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 diff --git a/app/views/admin/instances/index.html.haml b/app/views/admin/instances/index.html.haml index e5955e6bf..be21d6bf7 100644 --- a/app/views/admin/instances/index.html.haml +++ b/app/views/admin/instances/index.html.haml @@ -7,6 +7,6 @@ %th= t('admin.instances.domain_name') %th= t('admin.instances.account_count') %tbody - = render partial: 'instance', collection: @instances + = render @instances -= paginate @instances += paginate paginated_instances |