<commit_before>require 'faker'

User.delete_all
Article.delete_all
ArticleVersion.delete_all
UserType.delete_all

UserType.create!(name: "admin")
UserType.create!(name: "contributor")

users_desired = rand(15..25)
users_entered = User.count
users_needed = users_desired - users_entered

users_needed.times do
  user = User.new(
    username: "#{Faker::Name.first_name}.#{Faker::Name.last_name}".downcase,
    password: "password",
    type: UserType.find_by(name: "contributor")
    )

  user.save(validate: false)
end

articles_desired = rand(8..10)
articles_entered = Article.count
articles_needed = articles_desired - articles_entered

articles_needed.times do
  article = Article.new(
    is_featured: (rand(0..1)),
    title: Faker::Hipster.sentence(rand(5..10)), # move this to line 43.5 when migrations have been changed
    )

  article.save(validate: false)

  versions_desired = rand(3..5)
  versions_entered = versions.count
  versions_needed = versions_desired - versions_entered

  versions_needed.times do
    article_version = ArticleVersion.new(
      content: Faker::Hipster.paragraph(rand(1..3)),
      article: article,
      author: User.all.sample,
      is_draft: rand(0..1)
      )

    article_version.save(validate: false)
  end

end
<commit_msg>article.versions to fix seed file<commit_after>require 'faker'

User.delete_all
Article.delete_all
ArticleVersion.delete_all
UserType.delete_all

UserType.create!(name: "admin")
UserType.create!(name: "contributor")

users_desired = rand(15..25)
users_entered = User.count
users_needed = users_desired - users_entered

users_needed.times do
  user = User.new(
    username: "#{Faker::Name.first_name}.#{Faker::Name.last_name}".downcase,
    password: "password",
    type: UserType.find_by(name: "contributor")
    )

  user.save(validate: false)
end

articles_desired = rand(8..10)
articles_entered = Article.count
articles_needed = articles_desired - articles_entered

articles_needed.times do
  article = Article.new(
    is_featured: (rand(0..1)),
    title: Faker::Hipster.sentence(rand(5..10)), # move this to line 43.5 when migrations have been changed
    )

  article.save(validate: false)

  versions_desired = rand(3..5)
  versions_entered = article.versions.count
  versions_needed = versions_desired - versions_entered

  versions_needed.times do
    article_version = ArticleVersion.new(
      content: Faker::Hipster.paragraph(rand(1..3)),
      article: article,
      author: User.all.sample,
      is_draft: rand(0..1)
      )

    article_version.save(validate: false)
  end

end

{'fraction_non_alphanumeric': 0.11673151750972763, 'fraction_numerical': 0.01634241245136187, 'mean_word_length': 4.257668711656442, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5845849', 'n_tokens_mistral': 903, 'n_tokens_neox': 842, 'n_words': 166}