2012-11-30 09:36:41 +00:00
|
|
|
class MaxMindManager < BaseManager
|
|
|
|
|
|
|
|
|
|
def initialize(options={})
|
|
|
|
|
super(options)
|
|
|
|
|
end
|
2014-03-11 22:35:00 +00:00
|
|
|
|
2014-07-20 02:11:16 +00:00
|
|
|
def self.countries
|
2015-07-28 19:11:28 +00:00
|
|
|
Country.get_all.map { |c| {countrycode: c.countrycode, countryname: c.countryname} }
|
2014-03-18 03:20:41 +00:00
|
|
|
end
|
|
|
|
|
|
2012-12-15 20:17:41 +00:00
|
|
|
def self.regions(country)
|
2015-07-28 19:11:28 +00:00
|
|
|
Region.get_all(country).map { |r| { region: r.region, name: r.regionname } }
|
2015-05-06 20:35:41 +00:00
|
|
|
end
|
2012-12-15 20:17:41 +00:00
|
|
|
|
|
|
|
|
def self.cities(country, region)
|
2014-03-11 22:35:00 +00:00
|
|
|
City.get_all(country, region).map { |c| c.city }
|
2012-12-15 20:17:41 +00:00
|
|
|
end
|
|
|
|
|
|
2014-07-20 02:11:16 +00:00
|
|
|
def self.create_phony_database
|
|
|
|
|
GeoIpBlocks.connection.execute("select generate_scores_dataset()").check
|
2012-11-30 09:36:41 +00:00
|
|
|
end
|
|
|
|
|
|
2015-05-06 20:35:41 +00:00
|
|
|
private
|
2012-11-30 09:36:41 +00:00
|
|
|
|
2013-05-16 17:45:10 +00:00
|
|
|
def clear_location_table
|
2014-07-20 02:11:16 +00:00
|
|
|
@pg_conn.exec("DELETE FROM geoiplocations").clear
|
2013-05-16 17:45:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def clear_isp_table
|
2014-07-20 02:11:16 +00:00
|
|
|
@pg_conn.exec("DELETE FROM geoispip").clear
|
2012-11-30 09:36:41 +00:00
|
|
|
end
|
2015-05-06 20:35:41 +00:00
|
|
|
end # class MaxMindManager
|