<commit_before># encoding: utf-8

namespace :sisyphus do
  desc 'Update Sisyphus stuff'
  task :update => :environment do
    require 'open-uri'
    puts "#{Time.now.to_s}: Update Sisyphus stuff"
    puts "#{Time.now.to_s}: update *.src.rpm from Sisyphus to database"
    branch = Branch.where(name: 'Sisyphus', vendor: 'ALT Linux').first
    Srpm.import_all(branch, '/ALT/Sisyphus/files/SRPMS/*.src.rpm')
    Srpm.remove_old(branch, '/ALT/Sisyphus/files/SRPMS/')
    puts "#{Time.now.to_s}: end"
    puts "#{Time.now.to_s}: update *.i586.rpm/*.noarch.rpm/*.x86_64.rpm from Sisyphus to database"
    pathes = ['/ALT/Sisyphus/files/i586/RPMS/*.i586.rpm',
              '/ALT/Sisyphus/files/noarch/RPMS/*.noarch.rpm',
              '/ALT/Sisyphus/files/x86_64/RPMS/*.x86_64.rpm']
    Package.import_all(branch, pathes)
    puts "#{Time.now.to_s}: end"
    puts "#{Time.now.to_s}: update repocop cache"
    Repocop.update_repocop_cache
    puts "#{Time.now.to_s}: end"
    puts "#{Time.now.to_s}: expire cache"
    ['en', 'ru', 'uk', 'br'].each do |locale|
      ActionController::Base.new.expire_fragment("#{locale}_top15")
      ActionController::Base.new.expire_fragment("#{locale}_srpms_#{branch.name}_")
      pages_counter = branch.srpms.where("srpms.created_at > '2010-11-09 09:00:00'").count + 1
      for page in 1..pages_counter do
        ActionController::Base.new.expire_fragment("#{locale}_srpms_#{branch.name}_#{page}")
      end
    end
    # puts "#{Time.now.to_s}: update acls in redis cache"
    # Acl.update_redis_cache('ALT Linux', 'Sisyphus', 'http://git.altlinux.org/acl/list.packages.sisyphus')
    # puts "#{Time.now.to_s}: end"
  end

  # TODO:
  # desc 'Import all ACL for packages from Sisyphus to database'
  # task :acls => :environment do
  #   require 'open-uri'<commit_msg>We don't need update repocop status for packages after import b/c fresh repocop data not yet available.<commit_after># encoding: utf-8

namespace :sisyphus do
  desc 'Update Sisyphus stuff'
  task :update => :environment do
    require 'open-uri'
    puts "#{Time.now.to_s}: Update Sisyphus stuff"
    puts "#{Time.now.to_s}: update *.src.rpm from Sisyphus to database"
    branch = Branch.where(name: 'Sisyphus', vendor: 'ALT Linux').first
    Srpm.import_all(branch, '/ALT/Sisyphus/files/SRPMS/*.src.rpm')
    Srpm.remove_old(branch, '/ALT/Sisyphus/files/SRPMS/')
    puts "#{Time.now.to_s}: end"
    puts "#{Time.now.to_s}: update *.i586.rpm/*.noarch.rpm/*.x86_64.rpm from Sisyphus to database"
    pathes = ['/ALT/Sisyphus/files/i586/RPMS/*.i586.rpm',
              '/ALT/Sisyphus/files/noarch/RPMS/*.noarch.rpm',
              '/ALT/Sisyphus/files/x86_64/RPMS/*.x86_64.rpm']
    Package.import_all(branch, pathes)
    puts "#{Time.now.to_s}: end"
    puts "#{Time.now.to_s}: expire cache"
    # TODO: review and cleanup this code
    ['en', 'ru', 'uk', 'br'].each do |locale|
      ActionController::Base.new.expire_fragment("#{locale}_top15")
      ActionController::Base.new.expire_fragment("#{locale}_srpms_#{branch.name}_")
      pages_counter = branch.srpms.where("srpms.created_at > '2010-11-09 09:00:00'").count + 1
      for page in 1..pages_counter do
        ActionController::Base.new.expire_fragment("#{locale}_srpms_#{branch.name}_#{page}")
      end
    end
    # puts "#{Time.now.to_s}: update acls in redis cache"
    # Acl.update_redis_cache('ALT Linux', 'Sisyphus', 'http://git.altlinux.org/acl/list.packages.sisyphus')
    # puts "#{Time.now.to_s}: end"
  end

  # TODO:
  # desc 'Import all ACL for packages from Sisyphus to database'
  # task :acls => :environment do
  #   require 'open-uri'
{'fraction_non_alphanumeric': 0.16570008285004142, 'fraction_numerical': 0.022093344380005524, 'mean_word_length': 3.471604938271605, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '479130', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1370, 'n_words': 262}