<commit_before>class GeoActivity

  include Mongoid::Document

  embedded_in :user

  field :_id,          type: String
  field :dates,        type: Array,    default: -> { [DateTime.current.utc.to_date.to_s] }
  field :loc,          type: Array
  field :country_code, type: String
  field :city,         type: String

  validates_presence_of :id, :dates, :loc, :country_code, :city

  def self.record(ip: nil, user: nil)
    date     = DateTime.current.utc.to_date.to_s

    activity = user.geo_activities.where(_id: ip).first
    activity ||= user.geo_activities.new
    geo      = $geoip.look_up(ip)

    if activity && geo
      activity.id           ||= ip
      activity.city         ||= geo[:city]<commit_msg>Allow city to be missing.<commit_after>class GeoActivity

  include Mongoid::Document

  embedded_in :user

  field :_id,          type: String
  field :dates,        type: Array,    default: -> { [DateTime.current.utc.to_date.to_s] }
  field :loc,          type: Array
  field :country_code, type: String
  field :city,         type: String

  validates_presence_of :id, :dates, :loc, :country_code

  def self.record(ip: nil, user: nil)
    date     = DateTime.current.utc.to_date.to_s

    activity = user.geo_activities.where(_id: ip).first
    activity ||= user.geo_activities.new
    geo      = $geoip.look_up(ip)

    if activity && geo
      activity.id           ||= ip
      activity.city         ||= geo[:city]
{'fraction_non_alphanumeric': 0.11482254697286012, 'fraction_numerical': 0.0, 'mean_word_length': 2.5158924205378974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2102136', 'n_tokens_mistral': 487, 'n_tokens_neox': 464, 'n_words': 112}