<commit_before>require 'geoip'

class GeoCache
  
  cattr_reader :geo_lite_city
  @@geo_lite_city = GeoIP.new('tmp/GeoLiteCity.dat') rescue nil

  def self.latlon(ip_address)
    res = geo_lite_city.city(ip_address) rescue nil
    if res<commit_msg>Use installed geoip database on staging and live.<commit_after>require 'geoip'

class GeoCache

  cattr_reader :geo_lite_city
  if Rails.env.development?
    @@geo_lite_city = GeoIP.new('tmp/GeoLiteCity.dat') rescue nil
  else
    @@geo_lite_city = GeoIP.new('/usr/share/GeoIP/GeoLiteCity.dat') rescue nil
  end

  def self.latlon(ip_address)
    res = geo_lite_city.city(ip_address) rescue nil
    if res
{'fraction_non_alphanumeric': 0.0963302752293578, 'fraction_numerical': 0.0, 'mean_word_length': 4.368852459016393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7458990', 'n_tokens_mistral': 259, 'n_tokens_neox': 234, 'n_words': 50}