From 7b1c0019323c5b7b2d21d3950ce122deeb4594c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 24 Nov 2014 18:05:40 +0100 Subject: [PATCH] FIX: limit other accounts deletion to 50 accounts otherwise it'll feel too slow --- .../discourse/templates/components/ip-lookup.hbs | 4 ++-- app/controllers/admin/users_controller.rb | 2 ++ config/locales/client.en.yml | 2 +- lib/admin_user_index_query.rb | 7 ++++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/templates/components/ip-lookup.hbs b/app/assets/javascripts/discourse/templates/components/ip-lookup.hbs index 979ee6b4da7..f7c7851bfea 100644 --- a/app/assets/javascripts/discourse/templates/components/ip-lookup.hbs +++ b/app/assets/javascripts/discourse/templates/components/ip-lookup.hbs @@ -41,8 +41,8 @@ {{i18n ip_lookup.other_accounts}} {{other_accounts.length}} {{#if other_accounts.length}} - {{/if}} diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index c3208b369ec..9158fa52de3 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -278,6 +278,8 @@ class Admin::UsersController < Admin::AdminController params.require(:exclude) params.require(:order) + params[:limit] = 50 + user_destroyer = UserDestroyer.new(current_user) options = { delete_posts: true, block_email: true, block_urls: true, block_ip: true, delete_as_spammer: true } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 91a1dc961ff..0d189d93861 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -279,7 +279,7 @@ en: organisation: Organization phone: Phone other_accounts: "Other accounts with this IP address:" - delete_all: "Delete all" + delete_other_accounts: "Delete up to 50" username: "username" trust_level: "TL" read_time: "read time" diff --git a/lib/admin_user_index_query.rb b/lib/admin_user_index_query.rb index 17d07feb117..a5d3d66ff70 100644 --- a/lib/admin_user_index_query.rb +++ b/lib/admin_user_index_query.rb @@ -62,6 +62,11 @@ class AdminUserIndexQuery end end + def limit + limit = params[:limit].to_i + @query.limit(limit > 0 ? limit : 100) + end + # this might not be needed in rails 4 ? def append(active_relation) @query = active_relation if active_relation @@ -73,6 +78,7 @@ class AdminUserIndexQuery append filter_by_ip append filter_exclude append filter_by_search + append limit @query end @@ -85,6 +91,5 @@ class AdminUserIndexQuery .includes(:google_user_info) .includes(:oauth2_user_info) .includes(:user_open_ids) - .take(100) end end