<commit_before>require 'fb_service'

class User < ActiveRecord::Base
  has_one :person, :dependent => :destroy

  validates_presence_of :provider, :uid
  validates_uniqueness_of :uid, :scope => :provider

  delegate :network_activity, :to => :person

  def self.create_with_omniauth(auth)
    create! do |user|
      user.provider = auth["provider"]
      user.uid = auth["uid"]
      user.build_person(:name  => auth["user_info"]["name"].slice(0..19), 
                         :email => auth["user_info"]["email"],
                         :authorised_account => false)

      user.person.build_reputation_rating(:gift_actions  => 0,:distinct_people => 0, 
                                           :total_actions => 0, :positive_feedback => 0, 
                                           :negative_feedback => 0, :neutral_feedback => 0,
                                           :requests_received => 0, :requests_answered => 0, 
                                           :trusted_network_count => 0,  :activity_level => 0)
    end
    msg  = "has connected to sharedearth.net."
    link = "http://sharedearth.net"

    FbService.post_on_my_wall(auth["credentials"]["token"], msg, link, :append_name => true)
    User.find_by_uid(auth["uid"])
  end
  
  # Informs all the authorized user's friends
  def inform_mutural_friends(token)
    if person.authorised_account?
      event_log   = EventLog.fb_friend_join_event_log(person)
      friend_list = FbService.get_my_friends(token)

      friend_list.each do |friend|
        create_fb_event_entity(event_log, friend)
      end 

      create_fb_event_entity(event_log, person)
    end
  end
  
  # Available avatar sizes
  # :square (50x50, Facebook default)
  # :small  (50 pixels wide, variable height)
  # :large (about 200 pixels wide, variable height)
  # :medium (same as :large)<commit_msg>Added root_url to be more generic<commit_after>require 'fb_service'

class User < ActiveRecord::Base
  has_one :person, :dependent => :destroy

  validates_presence_of :provider, :uid
  validates_uniqueness_of :uid, :scope => :provider

  delegate :network_activity, :to => :person

  def self.create_with_omniauth(auth)
    create! do |user|
      user.provider = auth["provider"]
      user.uid = auth["uid"]
      user.build_person(:name  => auth["user_info"]["name"].slice(0..19), 
                         :email => auth["user_info"]["email"],
                         :authorised_account => false)

      user.person.build_reputation_rating(:gift_actions  => 0,:distinct_people => 0, 
                                           :total_actions => 0, :positive_feedback => 0, 
                                           :negative_feedback => 0, :neutral_feedback => 0,
                                           :requests_received => 0, :requests_answered => 0, 
                                           :trusted_network_count => 0,  :activity_level => 0)
    end
    msg  = "has connected to sharedearth.net."
    link = root_url

    FbService.post_on_my_wall(auth["credentials"]["token"], msg, link, :append_name => true)
    User.find_by_uid(auth["uid"])
  end
  
  # Informs all the authorized user's friends
  def inform_mutural_friends(token)
    if person.authorised_account?
      event_log   = EventLog.fb_friend_join_event_log(person)
      friend_list = FbService.get_my_friends(token)

      friend_list.each do |friend|
        create_fb_event_entity(event_log, friend)
      end 

      create_fb_event_entity(event_log, person)
    end
  end
  
  # Available avatar sizes
  # :square (50x50, Facebook default)
  # :small  (50 pixels wide, variable height)
  # :large (about 200 pixels wide, variable height)
  # :medium (same as :large)
{'fraction_non_alphanumeric': 0.10883620689655173, 'fraction_numerical': 0.011853448275862068, 'mean_word_length': 2.453953488372093, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2711711', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1071, 'n_words': 238}