<commit_before>require 'machinist/active_record'
require 'sham'
require 'faker'

#
# Common
#

def created_date(average_days = 30)
  (average_days + 5 + rand(5)).days.ago.to_s(:db)
end

def updated_date(average_days = 30)
  (average_days + rand(5)).days.ago.to_s(:db)
end

def boolean
  rand(2) == 1 ? true : false
end

Sham.title            { Faker::Lorem.sentence }
Sham.email            { Faker::Internet.email }
Sham.login            { Faker::Internet.user_name.gsub(/[^a-z]/, "") }
Sham.display_name     { Faker::Name.name }
Sham.summary          { Faker::Lorem.paragraph }

#
# Site
#
Site.blueprint do
  domain       "crabgrass.org"
  email_sender "robot@$current_host"
end

#
# Users
#
User.blueprint do
  login
  display_name
  email
  salt              { Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") }
  crypted_password  { Digest::SHA1.hexdigest("--#{salt}--#{login}--") }

  created_at        { created_date }
  last_seen_at      { updated_date }
end

#
# Groups
#

# requires :user
def Group.make_owned_by(attributes)
  raise "Missing keys (:user) are required for this blueprint" if !attributes.has_key?(:user)
  user = attributes.delete :user
  group = Group.make_unsaved(attributes)
  group.created_by = user
  group.save!
  group
end

Group.blueprint do
  full_name       { Sham.title }
  name            { full_name.gsub(/[^a-z]/,"") }<commit_msg>a blueprint for committees/councils. too long names were failing validations, so now group titles a somewhat shorter<commit_after>require 'machinist/active_record'
require 'sham'
require 'faker'

#
# Common
#

def created_date(average_days = 30)
  (average_days + 5 + rand(5)).days.ago.to_s(:db)
end

def updated_date(average_days = 30)
  (average_days + rand(5)).days.ago.to_s(:db)
end

def boolean
  rand(2) == 1 ? true : false
end

Sham.title            { Faker::Lorem.words(3).join(" ").capitalize }
Sham.email            { Faker::Internet.email }
Sham.login            { Faker::Internet.user_name.gsub(/[^a-z]/, "") }
Sham.display_name     { Faker::Name.name }
Sham.summary          { Faker::Lorem.paragraph }

#
# Site
#
Site.blueprint do
  domain       "crabgrass.org"
  email_sender "robot@$current_host"
end

#
# Users
#
User.blueprint do
  login
  display_name
  email
  salt              { Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") }
  crypted_password  { <PASSWORD>("--#{salt}--#{login}--") }

  created_at        { created_date }
  last_seen_at      { updated_date }
end

#
# Groups
#

# requires :user
def Group.make_owned_by(attributes)
  raise "Missing keys (:user) are required for this blueprint" if !attributes.has_key?(:user)
  user = attributes.delete :user
  group = Group.make_unsaved(attributes)
  group.created_by = user
  group.save!
  group
end

Group.blueprint do
  full_name       { Sham.title }
  name            { full_name.gsub(/[^a-z]/,"") }
end

Committee.blueprint do
  name            { Sham.title.gsub(/[^a-z]/,"")[0, 10] }
end

Council.blueprint do
{'fraction_non_alphanumeric': 0.145063801208865, 'fraction_numerical': 0.0083948959032908, 'mean_word_length': 3.103305785123967, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6843445', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1088, 'n_words': 210}