diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 93bd7412f..4bc882cb5 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -51,8 +51,13 @@ class ApplicationRecord < ActiveRecord::Base end def where_inet_matches(attr, value) - ip = IPAddress.parse(value) - where("#{qualified_column_for(attr)} <<= ?", ip.to_string) + if value.match?(/[, ]/) + ips = value.split(/[, ]+/).map { |ip| IPAddress.parse(ip).to_string } + where("#{qualified_column_for(attr)} = ANY(ARRAY[?]::inet[])", ips) + else + ip = IPAddress.parse(value) + where("#{qualified_column_for(attr)} <<= ?", ip.to_string) + end end def where_array_includes_any(attr, values) diff --git a/app/models/tag.rb b/app/models/tag.rb index 31bb57ed6..8af8d375f 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -371,8 +371,8 @@ class Tag < ApplicationRecord when /\A>(.+)/ return [:gt, parse_cast($1, type)] - when /,/ - return [:in, range.split(/,/).map {|x| parse_cast(x, type)}] + when /[, ]/ + return [:in, range.split(/[, ]+/).map {|x| parse_cast(x, type)}] else return [:eq, parse_cast(range, type)] diff --git a/app/views/ip_addresses/_index_by_ip_addr.html.erb b/app/views/ip_addresses/_index_by_ip_addr.html.erb index bd7518593..512bfced3 100644 --- a/app/views/ip_addresses/_index_by_ip_addr.html.erb +++ b/app/views/ip_addresses/_index_by_ip_addr.html.erb @@ -1,3 +1,7 @@ +

+ <%= link_to "Find all users associated with the top 10 IP addresses", ip_addresses_path(search: { ip_addr: @ip_addresses.map(&:to_s).take(10).join(" "), group_by: "user" }) %> +

+ diff --git a/app/views/ip_addresses/_index_by_user.html.erb b/app/views/ip_addresses/_index_by_user.html.erb index a5a50a00c..905dc363c 100644 --- a/app/views/ip_addresses/_index_by_user.html.erb +++ b/app/views/ip_addresses/_index_by_user.html.erb @@ -1,3 +1,7 @@ +

+ <%= link_to "Find all IP addresses associated with these users", ip_addresses_path(search: { user_id: @ip_addresses.map(&:user_id).join(" "), group_by: "ip_addr" }) %> +

+