jam-cloud/web/lib/max_mind_manager.rb

32 lines
778 B
Ruby
Raw Permalink Normal View History

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
def self.countries
Country.get_all.map { |c| {countrycode: c.countrycode, countryname: c.countryname} }
end
2012-12-15 20:17:41 +00:00
def self.regions(country)
Region.get_all(country).map { |r| { region: r.region, name: r.regionname } }
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
def self.create_phony_database
GeoIpBlocks.connection.execute("select generate_scores_dataset()").check
2012-11-30 09:36:41 +00:00
end
private
2012-11-30 09:36:41 +00:00
def clear_location_table
@pg_conn.exec("DELETE FROM geoiplocations").clear
end
def clear_isp_table
@pg_conn.exec("DELETE FROM geoispip").clear
2012-11-30 09:36:41 +00:00
end
end # class MaxMindManager