mirror of https://github.com/mastodon/mastodon
				
				
				
			Instances list in admin (#2095)
* Add admin/instances index action * Add link to instances admin page * View lists instances * Instances, grouped by domain, ordered by count * Use Account.remote scope * Extract method: Account.by_domain_accountspull/2064/merge
							parent
							
								
									66d8f99a30
								
							
						
					
					
						commit
						55e1503522
					
				@ -0,0 +1,15 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
module Admin
 | 
			
		||||
  class InstancesController < BaseController
 | 
			
		||||
    def index
 | 
			
		||||
      @instances = ordered_instances.page(params[:page])
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    private
 | 
			
		||||
 | 
			
		||||
    def ordered_instances
 | 
			
		||||
      Account.remote.by_domain_accounts
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@ -0,0 +1,15 @@
 | 
			
		||||
- content_for :page_title do
 | 
			
		||||
  = t('admin.instances.title')
 | 
			
		||||
 | 
			
		||||
%table.table
 | 
			
		||||
  %thead
 | 
			
		||||
    %tr
 | 
			
		||||
      %th= t('admin.instances.domain_name')
 | 
			
		||||
      %th= t('admin.instances.account_count')
 | 
			
		||||
  %tbody
 | 
			
		||||
    - @instances.each do |instance|
 | 
			
		||||
      %tr
 | 
			
		||||
        %td= instance.domain
 | 
			
		||||
        %td= instance.accounts_count
 | 
			
		||||
 | 
			
		||||
= paginate @instances
 | 
			
		||||
@ -0,0 +1,15 @@
 | 
			
		||||
require 'rails_helper'
 | 
			
		||||
 | 
			
		||||
RSpec.describe Admin::InstancesController, type: :controller do
 | 
			
		||||
  before do
 | 
			
		||||
    sign_in Fabricate(:user, admin: true), scope: :user
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe 'GET #index' do
 | 
			
		||||
    it 'returns http success' do
 | 
			
		||||
      get :index
 | 
			
		||||
 | 
			
		||||
      expect(response).to have_http_status(:success)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue