<commit_before>Notification.delete_all
Event.delete_all
Message.delete_all
User.delete_all
Project.delete_all
Post.delete_all
PostConversant.delete_all
Resource.delete_all
LikeFlag.delete_all
StayInformedFlag.delete_all
GetInvolvedFlag.delete_all
OmniauthAccount.delete_all

@users = []
@projects = []
@posts = []
@resources = []

@topher = FactoryGirl.create(:user,
  first_name: "Topher",
  last_name: "Hunt",
  email: "<EMAIL>"
)

puts "\nCreating 50 users..."
50.times do |i|
  print "."
  first_name = Faker::Name.first_name
  last_name = Faker::Name.last_name
  email = "#{first_name}.#{last_name}@<EMAIL>".downcase.gsub(/[^\w\@\.]/, '')
  user = FactoryGirl.create(:user, {
    first_name: first_name,
    last_name: last_name,
    email: email,
    location: Faker::LordOfTheRings.location
  })
  @users << user
end
@users = @users.sample(25) + [@topher]

# Make people follow other people first so that they receive notifications of followee activity.
puts "\nPeople following people..."
100.times do |i|
  print "."
  follower = @users.sample
  followee = @users.sample
  # Tolerate failure in case of duplicates
  if StayInformedFlag.create(user: follower, target: followee)
    Event.register(follower, :follow, followee)
  end
end
3.times do |i|
  print "."
  follower = @topher
  followee = @users.sample
  # Tolerate failure in case of duplicates
  if StayInformedFlag.create(user: follower, target: followee)
    Event.register(follower, :follow, followee)
  end
end

puts "\nCreating 25 projects..."
25.times do |i|
  print "."
  user = @users.sample
  # TODO: Add stock images... the lorempixel URL we were using, kept timing out
  project = FactoryGirl.create(:project, owner: user)
  Event.register(project.owner, :create, project)<commit_msg>Seed data has realish user and project pics<commit_after>Notification.delete_all
Event.delete_all
Message.delete_all
User.delete_all
Project.delete_all
Post.delete_all
PostConversant.delete_all
Resource.delete_all
LikeFlag.delete_all
StayInformedFlag.delete_all
GetInvolvedFlag.delete_all
OmniauthAccount.delete_all

@users = []
@projects = []
@posts = []
@resources = []

@topher = FactoryGirl.create(:user,
  first_name: "Topher",
  last_name: "Hunt",
  email: "<EMAIL>"
)

puts "\nCreating 50 users..."
50.times do |i|
  print "."
  # first_name = Faker::Name.first_name
  # last_name = Faker::Name.last_name
  # email = "#{first_name}.#{last_name}@example.com".downcase.gsub(/[^\w\@\.]/, '')
  # location = Faker::LordOfTheRings.location

  uri = URI.parse('https://randomuser.me/api/')
  response = Net::HTTP.get_response(uri)
  json = JSON.parse(response.body)['results'].first

  user = FactoryGirl.create(:user, {
    email: json['email'].gsub(/\s/, ''),
    first_name: json['name']['first'].capitalize,
    last_name: json['name']['last'].capitalize,
    location: json['location']['city'] + ' ' + json['location']['state'],
    image: json['picture']['large']
  })
  @users << user
end
@users = @users.sample(25) + [@topher]

# Make people follow other people first so that they receive notifications of followee activity.
puts "\nPeople following people..."
100.times do |i|
  print "."
  follower = @users.sample
  followee = @users.sample
  # Tolerate failure in case of duplicates
  if StayInformedFlag.create(user: follower, target: followee)
    Event.register(follower, :follow, followee)
  end
end
3.times do |i|
  print "."
  follower = @topher
  followee = @users.sample
  # Tolerate failure in case of duplicates
  if StayInformedFlag.create(user: follower, target: followee)
    Event.register(follower, :follow, followee)
  end
end

puts "\nCreating 25 projects..."
25.times do |i|
  print "."
  user = @users.sample
  # TODO: Add stock images... the lorempixel URL we were using, kept timing out
  project = FactoryGirl.create(:project,
    owner: user,
    image: "https://source.unsplash.com/random/200x200"
  )
  Event.register(project.owner, :create, project)
{'fraction_non_alphanumeric': 0.13971146545178437, 'fraction_numerical': 0.008605416350291066, 'mean_word_length': 4.355013550135501, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 6, 'https://': 2, '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': '558230', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1311, 'n_words': 319}