<commit_before>class User < ActiveRecord::Base
  attr_accessible :desc, :email, :fullname, :pic_url, :username, :website, :website2, :website3, :password, :password_confirmation
  # has_secure_password
  has_many :bookmarks, :dependent => :destroy
  has_many :tags
  has_many :followings, :dependent => :destroy 
  # validates_presence_of :password, :on => :create
  validates_presence_of :email, :presence => true, :uniqueness => true, :email_format => true
  validates_presence_of :username

  def self.from_omniauth(auth)
    where(auth.slice("provider", "uid")).first || create_from_omniauth(auth)
  end

  def self.create_from_omniauth(auth)
    create! do |user|
      user.provider = auth["provider"]
      user.uid = auth["uid"]
      user.username = auth["info"]["nickname"]
      if user.provider == "twitter"
        user.email = "<EMAIL>"
        user.pic_url = auth["info"]["image"]
      else 
        user.email = auth["info"]["email"]
      end

    end
  end

  # import bookmarks files to users account 
  def import_bookmarks(xml)
    doc = Nokogiri.XML(xml)
    doc.xpath('/posts/post').map do |p|
      b = Bookmark.where(:url => p["href"], :title => p["description"], :desc => p["extended"], :user_id => id, :hashed_url => p["hash"] ).first_or_create
      if p["tag"] then
        tags = p["tag"]
        tags = tags.split(" ").map do |tag|
          Tag.new(:name => tag.strip)
        end
        if b.save then
          tags.each { |t| t.bookmark_id = b.id; t.save }
        end
      else
        b.save
      end
    end
  end

  # handle_asynchronously with delayed_job
  # handle_asynchronously :import_bookmarks

end
<commit_msg>Adds updated_at and created_at fields when importing bookmarks<commit_after>class User < ActiveRecord::Base
  attr_accessible :desc, :email, :fullname, :pic_url, :username, :website, :website2, :website3, :password, :password_confirmation
  # has_secure_password
  has_many :bookmarks, :dependent => :destroy
  has_many :tags
  has_many :followings, :dependent => :destroy 
  # validates_presence_of :password, :on => :create
  validates_presence_of :email, :presence => true, :uniqueness => true, :email_format => true
  validates_presence_of :username

  def self.from_omniauth(auth)
    where(auth.slice("provider", "uid")).first || create_from_omniauth(auth)
  end

  def self.create_from_omniauth(auth)
    create! do |user|
      user.provider = auth["provider"]
      user.uid = auth["uid"]
      user.username = auth["info"]["nickname"]
      if user.provider == "twitter"
        user.email = "<EMAIL>"
        user.pic_url = auth["info"]["image"]
      else 
        user.email = auth["info"]["email"]
      end

    end
  end

  # import bookmarks files to users account 
  def import_bookmarks(xml)
    doc = Nokogiri.XML(xml)
    doc.xpath('/posts/post').map do |p|
      time = Time.parse(p["time"])
      b = Bookmark.where(:url => p["href"], :title => p["description"], :desc => p["extended"], :user_id => id, :hashed_url => p["hash"], :created_at => time, :updated_at => time ).first_or_create
      if p["tag"] then
        tags = p["tag"]
        tags = tags.split(" ").map do |tag|
          Tag.new(:name => tag.strip)
        end
        if b.save then
          tags.each { |t| t.bookmark_id = b.id; t.save }
        end
      else
        b.save
      end
    end
  end

  # handle_asynchronously with delayed_job
  # handle_asynchronously :import_bookmarks

end

{'fraction_non_alphanumeric': 0.14037122969837587, 'fraction_numerical': 0.001160092807424594, 'mean_word_length': 3.115751789976134, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2311565', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1130, 'n_words': 267}