<commit_before># This script is used by the gem seed-fu to populate the database with preload data. 
# It does not clear the database - mainly because that would mean deleting your admin login.
# All the numbers are pretty arbitrary, and can be changed to suit your needs, and how many records you want.
# As it stands, you'll need to follow the format and create a new seed generation block for each
# model you want to seed in the database, every time you create a model that isn't already here.

require 'seed-fu'
require 'ffaker'

#Method for prompting the user for the number of records per model they want to seed into the database.
def ask_for_records( model )
  STDOUT.puts "How many #{model} records would you like to generate? (please enter a number)"
  STDIN.gets.chomp.to_i
end


#Random object that is used throughout for generating fake data that FFaker can't
r = Random.new

#User generation
entered_num = ask_for_records("User")

if entered_num.integer? && entered_num >=0
  entered_num.times do
    User.seed do |u|
      u.first_name = Faker::Name.first_name
      u.last_name = Faker::Name.last_name
      u.nickname = Faker::Name.first_name
      u.phone = Faker::PhoneNumber.short_phone_number
      u.email = Faker::Internet.email
      u.login = (0...3).map{65.+(rand(25)).chr}.join.downcase + r.rand(2..99).to_s
      u.affiliation = "YC " + ["BK", "BR", "CC", "DC", "ES", "JE", "MC", "PC", "SM", "SY", "TC", "TD"].sample + " " + r.rand(2012..2015).to_s
    end
  end
else
  STDOUT.puts "Please enter a whole number."
  entered_num = STDIN.gets.chomp.to_i
end


#Category generation
entered_num = ask_for_records("Category")

if entered_num.integer? && entered_num >=0
  category = entered_num.times.map do
      Category.seed do |c|
      c.name = Faker::Product.brand
      c.max_per_user = r.rand(1..40)
      c.max_checkout_length = r.rand(1..40)
      c.sort_order = r.rand(100)
    end
  end
else
  STDOUT.puts "Please enter a whole number."
  entered_num = STDIN.gets.chomp.to_i
end


#EquipmentModel generation
entered_num = ask_for_records("EquipmentModel")

if entered_num.integer? && entered_num >=0
  equipment_model = entered_num.times.map do
    EquipmentModel.seed do |em|
      em.name = Faker::Product.product
      em.description = Faker::Lorem.paragraph(4)
      em.late_fee = r.rand(50.00..1000.00).round(2).to_d
      em.replacement_fee = r.rand(50.00..1000.00).round(2).to_d
      em.max_per_user = r.rand(1..40)
      em.active = true
      em.checkout_procedures = Faker::Lorem.sentences(4)
      em.checkin_procedures = Faker::Lorem.sentences(4)
      em.category_id = category.flatten[r.rand(0...category.length)].id
    end
  end
else
  STDOUT.puts "Please enter a whole number."
  entered_num = STDIN.gets.chomp.to_i
end


#EquipmentObject generation
entered_num = ask_for_records("EquipmentObject")

if entered_num.integer? && entered_num >=0
  entered_num.times do
    EquipmentObject.seed do |eo|
      eo.name = "Number #{(0...3).map{65.+(rand(25)).chr}.join}"
      eo.serial = (0...8).map{65.+(rand(25)).chr}.join
      eo.active = true
      eo.equipment_model_id = equipment_model.flatten[r.rand(0...equipment_model.length)].id
    end
  end
else
  STDOUT.puts "Please enter a whole number."
  entered_num = STDIN.gets.chomp.to_i
end<commit_msg>issue #58: final seed script for generating Users, Categories, EquipmentModels, and EquipmentObjects<commit_after># This script is used by the gem seed-fu to populate the database with preload data. 
# It does not clear the database - mainly because that would mean deleting your admin login.
# All the numbers are pretty arbitrary, and can be changed to suit your needs, and how many records you want.
# As it stands, you'll need to follow the format and create a new seed generation block for each
# model you want to seed in the database, every time you create a model that isn't already here.
# Right now, it only generates Users, Categories, EquipmentModels, and EquipmentObjects.

require 'seed-fu'
require 'ffaker'

#Method for prompting the user for the number of records per model they want to seed into the database.
def ask_for_records( model )
  STDOUT.puts "How many #{model} records would you like to generate? (please enter a number)"
  STDIN.gets.chomp.to_i
end


#Random object that is used throughout for generating fake data that FFaker can't
r = Random.new

if User.all.empty?
  STDOUT.puts "ERROR: You must sign into the app via CAS first to create a superuser account for your netID."
else
  #User generation
  entered_num = ask_for_records("User")

  if entered_num.integer? && entered_num >= 0
    entered_num.times do
      User.seed do |u|
        u.first_name = Faker::Name.first_name
        u.last_name = Faker::Name.last_name
        u.nickname = Faker::Name.first_name
        u.phone = Faker::PhoneNumber.short_phone_number
        u.email = Faker::Internet.email
        u.login = (0...3).map{65.+(rand(25)).chr}.join.downcase + r.rand(2..99).to_s
        u.affiliation = "YC " + ["BK", "BR", "CC", "DC", "ES", "JE", "MC", "PC", "SM", "SY", "TC", "TD"].sample + " " + r.rand(2012..2015).to_s
      end
    end
  else
    STDOUT.puts "Please enter a whole number."
    entered_num = STDIN.gets.chomp.to_i
  end


  #Category generation
  entered_num = ask_for_records("Category")

  if entered_num.integer? && entered_num > 0
    category = entered_num.times.map do
        Category.seed do |c|
        c.name = Faker::Product.brand
        c.max_per_user = r.rand(1..40)
        c.max_checkout_length = r.rand(1..40)
        c.sort_order = r.rand(100)
      end
    end
  else
    STDOUT.puts "Please enter a whole number greater than 0."
    entered_num = STDIN.gets.chomp.to_i
  end


  #EquipmentModel generation
  entered_num = ask_for_records("EquipmentModel")

  if entered_num.integer? && entered_num > 0
    equipment_model = entered_num.times.map do
      EquipmentModel.seed do |em|
        em.name = Faker::Product.product
        em.description = Faker::Lorem.paragraph(4)
        em.late_fee = r.rand(50.00..1000.00).round(2).to_d
        em.replacement_fee = r.rand(50.00..1000.00).round(2).to_d
        em.max_per_user = r.rand(1..40)
        em.active = true
        em.checkout_procedures = Faker::Lorem.sentences(4)
        em.checkin_procedures = Faker::Lorem.sentences(4)
        em.category_id = category.flatten[r.rand(0...category.length)].id
      end
    end
  else
    STDOUT.puts "Please enter a whole number greater than 0."
    entered_num = STDIN.gets.chomp.to_i
  end


  #EquipmentObject generation
  entered_num = ask_for_records("EquipmentObject")

  if entered_num.integer? && entered_num >= 0
    entered_num.times do
      EquipmentObject.seed do |eo|
        eo.name = "Number #{(0...3).map{65.+(rand(25)).chr}.join}"
        eo.serial = (0...8).map{65.+(rand(25)).chr}.join
        eo.active = true
        eo.equipment_model_id = equipment_model.flatten[r.rand(0...equipment_model.length)].id
      end
    end
  else
    STDOUT.puts "Please enter a whole number."
    entered_num = STDIN.gets.chomp.to_i
  end
end
{'fraction_non_alphanumeric': 0.11604624929498025, 'fraction_numerical': 0.02086858432036097, 'mean_word_length': 3.224538415723645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1485513', 'n_tokens_mistral': 2497, 'n_tokens_neox': 2364, 'n_words': 667}