Skip to content
Snippets Groups Projects
Commit 4968e91a authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge pull request #646 from krakatoa/master

Fixes on MaxMind
parents ff192526 88829395
No related branches found
No related tags found
No related merge requests found
......@@ -34,10 +34,10 @@ module Geocoder::Lookup
result.nil? ? [] : [result.to_hash]
elsif configuration[:package] == :city
addr = IPAddr.new(query.text).to_i
q = "SELECT l.country, l.region, l.city
q = "SELECT l.country, l.region, l.city, l.latitude, l.longitude
FROM maxmind_geolite_city_location l JOIN maxmind_geolite_city_blocks b USING (loc_id)
WHERE b.start_ip_num <= #{addr} AND #{addr} <= b.end_ip_num"
format_result(q, [:country_name, :region_name, :city_name])
format_result(q, [:country_name, :region_name, :city_name, :latitude, :longitude])
elsif configuration[:package] == :country
addr = IPAddr.new(query.text).to_i
q = "SELECT country, country_code FROM maxmind_geolite_country
......
......@@ -83,7 +83,7 @@ module Geocoder
case package
when :geolite_city_csv
# use the last two in case multiple versions exist
files = Dir.glob(File.join(dir, "GeoLiteCity_*/*.csv"))[-2..-1]
files = Dir.glob(File.join(dir, "GeoLiteCity_*/*.csv"))[-2..-1].sort
Hash[*files.zip(["maxmind_geolite_city_blocks", "maxmind_geolite_city_location"]).flatten]
when :geolite_country_csv
{File.join(dir, "GeoIPCountryWhois.csv") => "maxmind_geolite_country"}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment