From d8e84a90dc96af47e221a1d7effc251d873f2978 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Thu, 15 Oct 2015 12:12:21 -0700 Subject: [PATCH] Revert "fixes #2530: improved ip addr search" This reverts commit 1eb2d515fdcac4b71aee57e2a86e7874af88f309. Conflicts: app/views/moderator/ip_addrs/index.html.erb --- app/logical/moderator/ip_addr_search.rb | 35 -------------------- app/views/moderator/ip_addrs/index.html.erb | 23 +++---------- app/views/moderator/ip_addrs/search.html.erb | 1 + config/danbooru_default_config.rb | 2 +- 4 files changed, 7 insertions(+), 54 deletions(-) diff --git a/app/logical/moderator/ip_addr_search.rb b/app/logical/moderator/ip_addr_search.rb index da9f604ce..70231f23f 100644 --- a/app/logical/moderator/ip_addr_search.rb +++ b/app/logical/moderator/ip_addr_search.rb @@ -19,46 +19,11 @@ module Moderator end end - def find_common_users - user = User.find_by_name(params[:user_name]) - ip_addrs = Set.new - user_ids = {} - - ip_addrs.merge(find_distinct_ip_addrs("comments", "ip_addr", "creator_id", user.id)) - ip_addrs.merge(find_distinct_ip_addrs("post_versions", "updater_ip_addr", "updater_id", user.id)) - ip_addrs.merge(find_distinct_ip_addrs("note_versions", "updater_ip_addr", "updater_id", user.id)) - ip_addrs.merge(find_distinct_ip_addrs("pool_versions", "updater_ip_addr", "updater_id", user.id)) - ip_addrs.merge(find_distinct_ip_addrs("wiki_page_versions", "updater_ip_addr", "updater_id", user.id)) - ip_addrs.merge(find_distinct_ip_addrs("dmails", "creator_ip_addr", "from_id", user.id)) - - ip_addrs.each do |ip_addr| - find_distinct_user_ids(user_ids, "comments", "ip_addr", "creator_id", ip_addrs.to_a) - find_distinct_user_ids(user_ids, "post_versions", "updater_ip_addr", "updater_id", ip_addrs.to_a) - find_distinct_user_ids(user_ids, "note_versions", "updater_ip_addr", "updater_id", ip_addrs.to_a) - find_distinct_user_ids(user_ids, "pool_versions", "updater_ip_addr", "updater_id", ip_addrs.to_a) - find_distinct_user_ids(user_ids, "wiki_page_versions", "updater_ip_addr", "updater_id", ip_addrs.to_a) - find_distinct_user_ids(user_ids, "dmails", "creator_ip_addr", "from_id", ip_addrs.to_a) - end - - user_ids - end - private def select_all_sql(sql, *params) ActiveRecord::Base.select_all_sql(sql, *params) end - def find_distinct_ip_addrs(table_name, ip_field_name, user_field_name, user_id) - select_all_sql("select #{ip_field_name} from #{table_name} where updated_at >= ? and #{user_field_name} = ? group by #{ip_field_name}", 3.months.ago, user_id).rows.flatten - end - - def find_distinct_user_ids(user_ids, table_name, ip_field_name, user_field_name, ip_addrs) - select_all_sql("select #{user_field_name}, count(*) from #{table_name} where updated_at >= ? and #{ip_field_name} in (?) group by #{user_field_name}", 3.months.ago, ip_addrs).rows.each do |user_id, count| - user_ids[user_id] ||= 0 - user_ids[user_id] += count.to_i - end - end - def search_by_ip_addr(ip_addrs) sums = Hash.new {|h, k| h[k] = 0} diff --git a/app/views/moderator/ip_addrs/index.html.erb b/app/views/moderator/ip_addrs/index.html.erb index 3c71b18d1..bca873222 100644 --- a/app/views/moderator/ip_addrs/index.html.erb +++ b/app/views/moderator/ip_addrs/index.html.erb @@ -2,24 +2,11 @@

IP Addresses

-

The following users share IP addresses used by <%= params[:search][:user_name] %>. This searches across comments, post changes, note changes, pool changes, wiki changes, and dmails over the past 3 months.

- - - - - - - - - - <% @search.find_common_users.each do |user_id, count| %> - - - - - <% end %> - -
UserCount
<%= link_to User.id_to_name(user_id), user_path(user_id) %><%= count %>
+ <% if params[:search][:user_id].present? || params[:search][:user_name].present? %> + <%= render "ip_listing" %> + <% else %> + <%= render "user_listing" %> + <% end %>
diff --git a/app/views/moderator/ip_addrs/search.html.erb b/app/views/moderator/ip_addrs/search.html.erb index d6c0f7e95..51b21a81a 100644 --- a/app/views/moderator/ip_addrs/search.html.erb +++ b/app/views/moderator/ip_addrs/search.html.erb @@ -4,6 +4,7 @@ <%= form_tag(moderator_ip_addrs_path, :method => :get, :class => "simple_form") do %> <%= search_field "user_name", :label => "User" %> + <%= search_field "ip_addr", :label => "IP Addr" %> <%= submit_tag "Search" %> <% end %> diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index 5dddf45f4..5c6e1a37f 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -4,7 +4,7 @@ module Danbooru class Configuration # The version of this Danbooru. def version - "2.94.0" + "2.93.0" end # The name of this Danbooru.