jam-cloud/ruby/lib/jam_ruby/models/geo_ip_locations.rb

23 lines
799 B
Ruby
Raw Normal View History

2014-02-23 23:24:25 +00:00
module JamRuby
class GeoIpLocations < ActiveRecord::Base
self.table_name = 'geoiplocations'
def self.lookup(locid)
GeoIpLocations.where(locid: locid)
2014-02-23 23:24:25 +00:00
.limit(1)
.first
end
def self.createx(locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode)
c = connection.raw_connection
c.exec_params('insert into geoiplocations (locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode, geog) values($1, $2, $3, $4, $5, $6, $7, $8, $9, ST_SetSRID(ST_MakePoint($7, $6), 4326)::geography)',
[locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode])
2014-02-23 23:24:25 +00:00
end
def self.import_from_max_mind(file)
# todo implement import_from_max_mind
end
2014-02-23 23:24:25 +00:00
end
end