You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
724 B

  1. # frozen_string_literal: true
  2. require 'sidekiq-bulk'
  3. class Settings::FollowerDomainsController < Settings::BaseController
  4. def show
  5. @account = current_account
  6. @domains = current_account.followers.reorder(Arel.sql('MIN(follows.id) DESC')).group('accounts.domain').select('accounts.domain, count(accounts.id) as accounts_from_domain').page(params[:page]).per(10)
  7. end
  8. def update
  9. domains = bulk_params[:select] || []
  10. AfterAccountDomainBlockWorker.push_bulk(domains) do |domain|
  11. [current_account.id, domain]
  12. end
  13. redirect_to settings_follower_domains_path, notice: I18n.t('followers.success', count: domains.size)
  14. end
  15. private
  16. def bulk_params
  17. params.permit(select: [])
  18. end
  19. end