<commit_before># This can be run in the rails console to generate a csv of all course
# participants' usernames.

require 'csv'

# all the usernames
usernames = User.joins(:courses_users).uniq.pluck(:wiki_id)
CSV.open('/root/all_course_participants.csv', 'wb') do |csv|
  usernames.each do |username|
    csv << [username]
  end
end

# student usernames by cohort
Cohort.all.each do |cohort|
  CSV.open("/root/#{cohort.slug}_students.csv", 'wb') do |csv|
    cohort.students.each do |student|
      csv << [student.wiki_id]
    end
  end
end<commit_msg>Add script for getting usernames with courses<commit_after># This can be run in the rails console to generate a csv of all course
# participants' usernames.

require 'csv'

# all the usernames
usernames = User.joins(:courses_users).uniq.pluck(:wiki_id)
CSV.open('/root/all_course_participants.csv', 'wb') do |csv|
  usernames.each do |username|
    csv << [username]
  end
end

# student usernames by cohort
Cohort.all.each do |cohort|
  CSV.open("/root/#{cohort.slug}_students.csv", 'wb') do |csv|
    cohort.students.each do |student|
      csv << [student.wiki_id]
    end
  end
end

# student usernames and courses, by cohort
Cohort.all.each do |cohort|
  CSV.open("/root/#{cohort.slug}_students.csv", 'wb') do |csv|
    cohort.courses.each do |course|
      course.students.each do |student|
        csv << [student.wiki_id, course.slug]
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12649332396345747, 'fraction_numerical': 0.0, 'mean_word_length': 3.7946127946127945, 'pattern_counts': {'":': 0, '<': 13, '<?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': '6070173', 'n_tokens_mistral': 526, 'n_tokens_neox': 513, 'n_words': 141}