<commit_before>class SearchFingerprint < ActiveRecord::Base
  visitable

  after_create :create_user_fingerprint

  private

  def create_user_fingerprint
    fingerprint_already_exists = UserFingerprint.find_by_visit_id(self.visit.id)
    unless fingerprint_already_exists
      UserFingerprint.create do |uf|
        unless self.visit.ip.empty?
          if '127.0.0.1' == self.visit.ip
            uf.bot_visitor = false
            uf.in_district = true
            uf.localhost = true
            uf.on_campus = true<commit_msg>Improving localhost detection for analytics<commit_after>class SearchFingerprint < ActiveRecord::Base
  visitable

  after_create :create_user_fingerprint

  private

  def create_user_fingerprint
    fingerprint_already_exists = UserFingerprint.find_by_visit_id(self.visit.id)
    unless fingerprint_already_exists
      UserFingerprint.create do |uf|
        unless self.visit.ip.empty?
          if ['127.0.0.1', '0:0:0:0:0:0:0:1'].include? self.visit.ip
            uf.bot_visitor = false
            uf.in_district = true
            uf.localhost = true
            uf.on_campus = true
{'fraction_non_alphanumeric': 0.07658058771148708, 'fraction_numerical': 0.017809439002671415, 'mean_word_length': 2.8758620689655174, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4916181', 'n_tokens_mistral': 374, 'n_tokens_neox': 341, 'n_words': 62}