<commit_before>namespace :gems_status do
  desc "Run gems-status"
  task :run => :environment do
    RubyApplication.all.each do |ra|
      conf = {
        "classname" => "LockfileGems",
        "filename" => ra.filename,
        "gems_url" => ra.gems_url
      }
      runner = GemsStatus::Runner.new
      runner.source = GemsStatus::LockfileGems.new(conf)
      source_repos = {}
      SourceRepo.all.to_a.each { |a| source_repos[a.name] = a.url }
      fixed = {}
      SecurityAlert.all.each do |sa|
        next if sa.sec_key.nil? || sa.sec_key.blank? || sa.version_fix.nil? || 
          sa.version_fix.blank? || sa.version_fix == "0.0.0"
        fixed[sa.sec_key] = sa.version_fix

      end
      conf = {
        "classname" => "NotASecurityAlertChecker",
        "fixed" => fixed,
        "source_repos" => source_repos,
        "email_username" => CONFIG["GMAIL_USERNAME"],
        "email_password" => CONFIG["<PASSWORD>"],
        "mailing_lists" => [
          '<EMAIL>'
        ],
        "email_to" => [ra.user.email]

      }
      runner.add_checker(GemsStatus::NotASecurityAlertChecker.new(conf))
      runner.execute
      puts "DEBUG: ------- Inserting into database -----------------"
      puts "DEBUG: Inserting gems"
      runner.gem_list.each do |name, gem|
        puts "DEBUG: #{name}"
        if !RubyGem.exists?(:name => gem.name, :version => gem.version.to_s)
          rg = RubyGem.new
          rg.name = gem.name
          rg.version = gem.version.to_s
          rg.license = gem.license
          rg.ruby_applications = [ra]
          rg.save
        else<commit_msg>create fixed array depending on the status of the security alert<commit_after>namespace :gems_status do
  desc "Run gems-status"
  task :run => :environment do
    RubyApplication.all.each do |ra|
      conf = {
        "classname" => "LockfileGems",
        "filename" => ra.filename,
        "gems_url" => ra.gems_url
      }
      runner = GemsStatus::Runner.new
      runner.source = GemsStatus::LockfileGems.new(conf)
      source_repos = {}
      SourceRepo.all.to_a.each { |a| source_repos[a.name] = a.url }
      fixed = {}
      SecurityAlert.all.each do |sa|
        next if sa.sec_key.nil? || sa.sec_key.blank?
        if sa.status == 2 || sa.status == 3
          fixed[sa.sec_key] = "0.0.0"
        elsif sa.status == 1 && !sa.version_fix.nil? && !sa.version_fix.blank?
          fixed[sa.sec_key] = sa.version_fix
        end
      end
      conf = {
        "classname" => "NotASecurityAlertChecker",
        "fixed" => fixed,
        "source_repos" => source_repos,
        "email_username" => CONFIG["GMAIL_USERNAME"],
        "email_password" => CONFIG["<PASSWORD>"],
        "mailing_lists" => [
          '<EMAIL>'
        ],
        "email_to" => [ra.user.email]

      }
      runner.add_checker(GemsStatus::NotASecurityAlertChecker.new(conf))
      runner.execute
      puts "DEBUG: ------- Inserting into database -----------------"
      puts "DEBUG: Inserting gems"
      runner.gem_list.each do |name, gem|
        puts "DEBUG: #{name}"
        if !RubyGem.exists?(:name => gem.name, :version => gem.version.to_s)
          rg = RubyGem.new
          rg.name = gem.name
          rg.version = gem.version.to_s
          rg.license = gem.license
          rg.ruby_applications = [ra]
          rg.save
        else
{'fraction_non_alphanumeric': 0.1483697277894107, 'fraction_numerical': 0.0026921926413401138, 'mean_word_length': 2.045537340619308, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, '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': '5191911', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1090, 'n_words': 206}