<commit_before>desc 'Mark inactive projects'
task check_for_inactive_projects: :environment do
  count = 0
  Project.active.all.each do |project|
    begin
      user = User.load_user
      score = project.score(user.nickname, user.token)
    rescue Octokit::NotFound
      score = 0
    rescue Octokit::Unauthorized
      score = 99
    end

    puts "#{project.name} - #{score}"

    if score == 0
      project.deactivate!
      count += 1
    end
  end

  puts "#{count} projects have been deactivated!"
end

task map_labels_from_github_issues: :environment do
  ACTIVE_LABELS = Label.all.map(&:name)

  Project.active.all.each do |project|
    user = User.load_user
    labels = project.issues(user.nickname, user.token, 6, open: true).map do |issue|
      issue.labels.map(&:name)
    end.flatten rescue []

    labels.try(:uniq!)

    labels.reject! { |label| !ACTIVE_LABELS.include?(label) }
    labels.each { |name| project.labels << Label.find_by_name(name) rescue nil }<commit_msg>Remove any projects with a score less than 5<commit_after>desc 'Mark inactive projects'
task check_for_inactive_projects: :environment do
  count = 0
  Project.active.all.each do |project|
    begin
      user = User.load_user
      score = project.score(user.nickname, user.token)
    rescue Octokit::NotFound
      score = 0
    rescue Octokit::Unauthorized
      score = 99
    end

    puts "#{project.name} - #{score}"

    if score < 5
      project.deactivate!
      count += 1
    end
  end

  puts "#{count} projects have been deactivated!"
end

task map_labels_from_github_issues: :environment do
  ACTIVE_LABELS = Label.all.map(&:name)

  Project.active.all.each do |project|
    user = User.load_user
    labels = project.issues(user.nickname, user.token, 6, open: true).map do |issue|
      issue.labels.map(&:name)
    end.flatten rescue []

    labels.try(:uniq!)

    labels.reject! { |label| !ACTIVE_LABELS.include?(label) }
    labels.each { |name| project.labels << Label.find_by_name(name) rescue nil }
{'fraction_non_alphanumeric': 0.11370407149950347, 'fraction_numerical': 0.007447864945382324, 'mean_word_length': 3.189189189189189, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, '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': '1424495', 'n_tokens_mistral': 670, 'n_tokens_neox': 654, 'n_words': 164}