<commit_before>class Leader < ActiveRecord::Base
  #validates_presence_of :package, :login
  belongs_to :branch
  belongs_to :packager
  belongs_to :srpm

  def self.import_leaders(vendor, branch, url)
    br = Branch.first :conditions => { :name => branch, :vendor => vendor }
    if br.leaders.count(:all) == 0
      ActiveRecord::Base.transaction do
        file = open(URI.escape(url)).read
        file.each_line do |line|
          package = line.split[0]
          srpm = Srpm.first :conditions => { :name => package, :branch_id => br.id }
          login = line.split[1]
          login = 'php-coder' if login == 'php_coder'
          login = 'p_solntsev' if login == 'psolntsev'
          login = '@vim-plugins' if login == '@vim_plugins'
          packager = Packager.first :conditions => { :login => login }
          if packager.nil?
            puts "BAD: " + login
          elsif srpm.nil?
            puts "BAD: " + package
          else 
            #Leader.create :package => package, :login => login, :branch_id => br.id
            # FIXME: if leader not packager, it will broke
            Leader.create :srpm_id => srpm.id, :branch_id => br.id, :packager_id => packager.id
          end
        end      
      end
    else<commit_msg>add more debug info<commit_after>class Leader < ActiveRecord::Base
  #validates_presence_of :package, :login
  belongs_to :branch
  belongs_to :packager
  belongs_to :srpm

  def self.import_leaders(vendor, branch, url)
    br = Branch.first :conditions => { :name => branch, :vendor => vendor }
    if br.leaders.count(:all) == 0
      ActiveRecord::Base.transaction do
        file = open(URI.escape(url)).read
        file.each_line do |line|
          package = line.split[0]
          srpm = Srpm.first :conditions => { :name => package, :branch_id => br.id }
          login = line.split[1]
          login = 'php-coder' if login == 'php_coder'
          login = 'p_solntsev' if login == 'psolntsev'
          login = '@vim-plugins' if login == '@vim_plugins'
          packager = Packager.first :conditions => { :login => login }
          if packager.nil?
            puts "BAD login: " + login
          elsif srpm.nil?
            puts "BAD package: " + package
          else 
            #Leader.create :package => package, :login => login, :branch_id => br.id
            # FIXME: if leader not packager, it will broke
            Leader.create :srpm_id => srpm.id, :branch_id => br.id, :packager_id => packager.id
          end
        end      
      end
    else
{'fraction_non_alphanumeric': 0.12145110410094637, 'fraction_numerical': 0.002365930599369085, 'mean_word_length': 2.163341645885287, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '4291734', 'n_tokens_mistral': 792, 'n_tokens_neox': 785, 'n_words': 206}