diff --git a/lib/generators/geocoder/templates/migration/maxmind_geolite_city.rb b/lib/generators/geocoder/templates/migration/maxmind_geolite_city.rb index 5c7b863e9f33f64d3ec45991109b97c19e784cfc..3904d9d76733bc727609a3ddbfa89a53223e1e27 100644 --- a/lib/generators/geocoder/templates/migration/maxmind_geolite_city.rb +++ b/lib/generators/geocoder/templates/migration/maxmind_geolite_city.rb @@ -1,13 +1,13 @@ class GeocoderMaxmindGeoliteCity < ActiveRecord::Migration def change - create_table :maxmind_blocks, id: false do |t| + create_table :maxmind_geolite_city_blocks, id: false do |t| t.column :startIpNum, 'integer unsigned', null: false t.column :endIpNum, 'integer unsigned', null: false t.column :locId, 'integer unsigned', null: false end - add_index :maxmind_blocks, :startIpNum, unique: true + add_index :maxmind_geolite_city_blocks, :startIpNum, unique: true - create_table :maxmind_location, id: false do |t| + create_table :maxmind_geolite_city_location, id: false do |t| t.column :locId, 'integer unsigned', null: false t.string :country, null: false t.string :region, null: false @@ -18,6 +18,6 @@ class GeocoderMaxmindGeoliteCity < ActiveRecord::Migration t.integer :metroCode t.integer :areaCode end - add_index :maxmind_location, :locId, unique: true + add_index :maxmind_geolite_city_location, :locId, unique: true end end diff --git a/lib/geocoder/lookups/maxmind_local.rb b/lib/geocoder/lookups/maxmind_local.rb index 3d58546d90d4016544289ebda3fb2f5aa01063ee..7ba53b05cc3b734bee20cd730b77ed06a5678f89 100644 --- a/lib/geocoder/lookups/maxmind_local.rb +++ b/lib/geocoder/lookups/maxmind_local.rb @@ -35,7 +35,7 @@ module Geocoder::Lookup else addr = IPAddr.new(query.text).to_i q = "SELECT l.country, l.region, l.city - FROM maxmind_location l JOIN maxmind_blocks b USING (locId) + FROM maxmind_geolite_city_location l JOIN maxmind_geolite_city_blocks b USING (locId) WHERE b.startIpNum <= #{addr} AND #{addr} <= b.endIpNum" if r = ActiveRecord::Base.connection.execute(q).first [Hash[*[:country_name, :region_name, :city_name].zip(r).flatten]] diff --git a/lib/maxmind_database.rb b/lib/maxmind_database.rb index 53a4a53331c1374d0642b000c17686187e851143..efcbe56e2f1d90eb3df6a5dda0f030607b4932e8 100644 --- a/lib/maxmind_database.rb +++ b/lib/maxmind_database.rb @@ -47,7 +47,7 @@ module Geocoder end end insert_into_table(table, headers, rows) if rows.size > 0 - puts "finished (#{Time.now - start_time} seconds)" + puts "done (#{Time.now - start_time} seconds)" end end @@ -78,7 +78,7 @@ module Geocoder when :geolite_city_csv # use the last two in case multiple versions exist files = Dir.glob(File.join(dir, "GeoLiteCity_*/*.csv"))[-2..-1] - Hash[*files.zip(["maxmind_blocks", "maxmind_location"]).flatten] + Hash[*files.zip(["maxmind_geolite_city_blocks", "maxmind_geolite_city_location"]).flatten] end end