<commit_before># frozen_string_literal: true

namespace :concept_results_migration do
  task migrate_from_csv: :environment do
    pipe_data = $stdin.read unless $stdin.tty?

    unless pipe_data
      puts 'No data detected on STDIN.  You must pass data to the task for it to run.  Example:'
      puts '  rake users:refresh_school_subscriptions < path/to/local/file.csv'
      puts ''
      puts 'If you are piping data into Heroku, you need to include the --no-tty flag:'
      puts '  heroku run rake users:refresh_school_subscriptions -a empirical-grammar --no-tty < path/to/local/file.csv'
      exit 1
    end

    CSV.parse(pipe_data, headers: true) do |row|
      CopyOldConceptResultsToConceptResultsWorker.perform_async(row['start_id'], row['max_id'], true)
    rescue
      puts "Failed to enqueue worker for range (#{row['start_id']}..#{row['max_id']})"
    end
  end
end<commit_msg>Fix copy/pasted documentation for a rake task (#9471)<commit_after># frozen_string_literal: true

namespace :concept_results_migration do
  task migrate_from_csv: :environment do
    pipe_data = $stdin.read unless $stdin.tty?

    unless pipe_data
      puts 'No data detected on STDIN.  You must pass data to the task for it to run.  Example:'
      puts '  rake concept_results_migration:migrate_from_csv < path/to/local/file.csv'
      puts ''
      puts 'If you are piping data into Heroku, you need to include the --no-tty flag:'
      puts '  heroku run rake concept_results_migration:migrate_from_csv -a empirical-grammar --no-tty < path/to/local/file.csv'
      exit 1
    end

    CSV.parse(pipe_data, headers: true) do |row|
      CopyOldConceptResultsToConceptResultsWorker.perform_async(row['start_id'], row['max_id'], true)
    rescue
      puts "Failed to enqueue worker for range (#{row['start_id']}..#{row['max_id']})"
    end
  end
end
{'fraction_non_alphanumeric': 0.09848484848484848, 'fraction_numerical': 0.003246753246753247, 'mean_word_length': 3.565432098765432, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4890154', 'n_tokens_mistral': 606, 'n_tokens_neox': 605, 'n_words': 178}