Add a new IP address search page at /ip_addresses. Replaces the old search page at /moderator/ip_addrs. On user profile pages, show the user's last known IP to mods. Also add search links for finding other IPs or accounts associated with the user. IP address search uses a big UNION ALL statement to merge IP addresses across various tables into a single view. This makes searching easier, but is known to timeout in certain cases. Fixes #4207 (the new IP search page supports searching by subnet).
18 lines
568 B
Ruby
18 lines
568 B
Ruby
class IpAddressesController < ApplicationController
|
|
respond_to :html, :xml, :json
|
|
before_action :moderator_only
|
|
|
|
def index
|
|
if search_params[:group_by] == "ip_addr"
|
|
@ip_addresses = IpAddress.search(search_params).group_by_ip_addr
|
|
respond_with(@ip_addresses)
|
|
elsif search_params[:group_by] == "user"
|
|
@ip_addresses = IpAddress.search(search_params).group_by_user
|
|
respond_with(@ip_addresses)
|
|
else
|
|
@ip_addresses = IpAddress.includes(:user, :model).paginated_search(params)
|
|
respond_with(@ip_addresses)
|
|
end
|
|
end
|
|
end
|