<commit_before>require 'open-uri'
require 'digest/md5'
require 'redis/objects'

class User
  include Mongoid::Document
  include Mongoid::Timestamps
  include Redis::Objects

  USERNAME_MAX_LENGTH = 20

  # Virtual attribute for authenticating by either username or email
  # This is in addition to a real persisted field like 'username'
  attr_accessor :login

  attr_accessor :tos_first_name, :tos_last_name

  field :username
  field :first_name
  field :last_name
  field :identities, type: Hash, default: {}

  index(username: 1)
  index({ "identities.facebook.uid" => 1 }, { sparse: true, unique: true })
  index({ "identities.twitter.uid" => 1 }, { sparse: true, unique: true })

  field :registration_code

  field :twitter
  field :location
  field :biography

  field :graph_user_id<commit_msg>boyscouting added note concerning user-name risks. <commit_after>require 'open-uri'
require 'digest/md5'
require 'redis/objects'

class User
  include Mongoid::Document
  include Mongoid::Timestamps
  include Redis::Objects

  USERNAME_MAX_LENGTH = 20 # WARNING: must be shorter than mongo ids(24 chars) to avoid confusing ids with usernames!

  # Virtual attribute for authenticating by either username or email
  # This is in addition to a real persisted field like 'username'
  attr_accessor :login

  attr_accessor :tos_first_name, :tos_last_name

  field :username
  field :first_name
  field :last_name
  field :identities, type: Hash, default: {}

  index(username: 1)
  index({ "identities.facebook.uid" => 1 }, { sparse: true, unique: true })
  index({ "identities.twitter.uid" => 1 }, { sparse: true, unique: true })

  field :registration_code

  field :twitter
  field :location
  field :biography

  field :graph_user_id
{'fraction_non_alphanumeric': 0.09268854346574554, 'fraction_numerical': 0.008059873344847437, 'mean_word_length': 4.535031847133758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2323219', 'n_tokens_mistral': 562, 'n_tokens_neox': 526, 'n_words': 175}