class MaxMindManager < BaseManager
  
  def initialize(options={})
    super(options)
  end

  def self.countries
    Country.get_all.map { |c| {countrycode: c.countrycode, countryname: c.countryname} }
  end

  def self.regions(country)
    Region.get_all(country).map { |r| { region: r.region, name: r.regionname } }
  end    
  
  def self.cities(country, region)
    City.get_all(country, region).map { |c| c.city }
  end

  def self.create_phony_database
    GeoIpBlocks.connection.execute("select generate_scores_dataset()").check
  end
    
private

  def clear_location_table
    @pg_conn.exec("DELETE FROM geoiplocations").clear
  end

  def clear_isp_table
    @pg_conn.exec("DELETE FROM geoispip").clear
  end
end # class MaxMindManager