<commit_before>class User < ActiveRecord::Base
  #can't rely on rpx to give more than this
  validates_presence_of :identifier

  has_many :events
  has_many :friendships
  has_many :friends, :through => :friendships
  is_gravtastic!

  def self.search(search, page)
    paginate :per_page => 10, :page => page,
             :conditions => ['username like ? or email like ?', 
             "%#{search}%", "%#{search}%"], :order => 'username'
  end

  def self.find_or_create_with_rpx(data)
    user = self.find_by_identifier(data[:identifier])
    if user.nil?
      user = self.new
      user.identifier = data[:identifier]
      user.username = data[:preferredUsername]  || data[:username]
      user.email = data[:verifiedEmail] || data[:email]
      user.name = data[:displayName]
      user.save!
    end

    user
  end

  def is_friend? friend
    if self.friends(true).include?(friend)
      return true
    else
      return false
    end
  end

  def collect_events
    all_events = []
    self.events.each do |event|
      editable = true
      all_events << event.to_timeline(editable)
    end
    self.friendships.each do |friendship|
      if friendship.selected
        more_events = Event.all_public(friendship.friend)
        more_events.each do |event|
          editable = false
          event.title = "[" + friendship.friend.username + "] " + event.title
          all_events << event.to_timeline(editable)
        end
      end
    end
    all_events
  end

end<commit_msg>Colored event texts of friends' events<commit_after>class User < ActiveRecord::Base
  #can't rely on rpx to give more than this
  validates_presence_of :identifier

  has_many :events
  has_many :friendships
  has_many :friends, :through => :friendships
  is_gravtastic!

  def self.search(search, page)
    paginate :per_page => 10, :page => page,
             :conditions => ['username like ? or email like ?', 
             "%#{search}%", "%#{search}%"], :order => 'username'
  end

  def self.find_or_create_with_rpx(data)
    user = self.find_by_identifier(data[:identifier])
    if user.nil?
      user = self.new
      user.identifier = data[:identifier]
      user.username = data[:preferredUsername]  || data[:username]
      user.email = data[:verifiedEmail] || data[:email]
      user.name = data[:displayName]
      user.save!
    end

    user
  end

  def is_friend? friend
    if self.friends(true).include?(friend)
      return true
    else
      return false
    end
  end

  def collect_events
    all_events = []
    self.events.each do |event|
      editable = true
      all_events << event.to_timeline(editable)
    end
    self.friendships.each do |friendship|
      if friendship.selected
        more_events = Event.all_public(friendship.friend)
        more_events.each do |event|
          editable = false
          event.title = "[" + friendship.friend.username + "] " + event.title
          colored = event.to_timeline(editable)
          colored.update({:color => "#099"})
          all_events << colored
        end
      end
    end
    all_events
  end

end
{'fraction_non_alphanumeric': 0.10848445595854922, 'fraction_numerical': 0.0022668393782383418, 'mean_word_length': 2.6213364595545134, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, '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': '2711695', 'n_tokens_mistral': 968, 'n_tokens_neox': 944, 'n_words': 228}