2015-03-09 14:44:12 +00:00
namespace :db do
2014-07-14 20:53:04 +00:00
2015-03-09 14:44:12 +00:00
desc " Imports a maxmind release from S3. If you specify a RELEASE env var, it should be like 2014-07-01 (YYYY-MM-DD). Otherwise latest found max_mind_releases in db is used. "
task import_maxmind : :environment do | task , args |
2014-07-14 20:53:04 +00:00
specific_release = ENV [ 'RELEASE' ]
if specific_release
release = MaxMindRelease . find_by_released_at ( Date . parse ( specific_release ) )
else
release = MaxMindRelease . order ( 'released_at DESC' ) . first
end
2014-07-20 02:11:16 +00:00
if release . imported && ENV [ 'REIMPORT' ] != '1'
puts " The MaxMindRelease for #{ release . released_at } has already been imported. "
puts " If you really want to import it again, specify REIMPORT=1 "
return
end
2013-05-16 17:45:10 +00:00
2014-07-20 02:11:16 +00:00
release . import ( ENV [ 'FORCE_FROM_SOURCE' ] == '1' )
2012-11-30 09:36:41 +00:00
end
2014-03-09 06:22:51 +00:00
desc " Import a maxmind blocks (134) database; run like this: rake db:import_geoip_blocks file=<path_to_GeoIPCity-134-Blocks.csv> "
task import_geoip_blocks : :environment do
GeoIpBlocks . import_from_max_mind ENV [ 'file' ]
end
desc " Import a maxmind locations (134) database; run like this: rake db:import_geoip_locations file=<path_to_GeoIPCity-134-Location.csv> "
task import_geoip_locations : :environment do
GeoIpLocations . import_from_max_mind ENV [ 'file' ]
end
desc " Import a maxmind isp (124) database; run like this: rake db:import_jam_isp file=<path_to_GeoIPISP.csv> "
task import_jam_isp : :environment do
JamIsp . import_from_max_mind ENV [ 'file' ]
end
2014-03-11 18:20:00 +00:00
desc " Import a iso3166 country database (countrycodes and names); run like this: rake db:import_countries file=/path/to/iso3166.csv "
task import_countries : :environment do
Country . import_from_iso3166 ENV [ 'file' ]
end
2014-05-22 20:17:00 +00:00
desc " Import a region database (countrycode, regioncode, regionname); run like this: rake db:import_regions file=/path/to/region_codes.csv "
2014-03-11 18:20:00 +00:00
task import_regions : :environment do
2014-05-22 20:17:00 +00:00
Region . import_from_region_codes ( ENV [ 'file' ] )
2014-03-11 18:20:00 +00:00
end
2014-03-09 22:35:12 +00:00
desc " Help "
task help : :environment do
2014-07-20 02:11:16 +00:00
puts " bundle exec rake db:import_maxmind "
2014-03-11 18:20:00 +00:00
puts " bundle exec rake db:import_maxmind_isp file=/path/to/GeoIPISP-142.csv # geo-142 "
puts " bundle exec rake db:import_maxmind_geo file=/path/to/GeoIPCity.csv # geo-139 "
puts " bundle exec rake db:import_geoip_blocks file=/path/to/GeoIPCity-134-Blocks.csv # geo-134 "
puts " bundle exec rake db:import_geoip_locations file=/path/to/GeoIPCity-134-Location.csv # geo-134 "
puts " bundle exec rake db:import_jam_isp file=/path/to/GeoIPISP.csv # geo-124 "
puts " bundle exec rake db:import_countries file=/path/to/iso3166.csv # db/geodata "
2014-05-22 20:17:00 +00:00
puts " bundle exec rake db:import_regions file=/path/to/region_codes.csv # db/geodata "
2014-03-09 22:35:12 +00:00
end
2012-11-30 09:36:41 +00:00
desc " Create a fake set of maxmind data "
2014-02-19 22:56:13 +00:00
task phony_maxmind : :environment do
2012-11-30 09:36:41 +00:00
MaxMindManager . active_record_transaction do | manager |
2014-07-20 02:11:16 +00:00
MaxMindManager . create_phony_database
2012-11-30 09:36:41 +00:00
end
end
end