brookr (owner)

Forks

Revisions

gist: 118332 Download_button fork
public
Public Clone URL: git://gist.github.com/118332.git
Ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
gem 'faker'
require 'faker'
# Clean out what is there
 
# Makes a bunch of different types of events per day at a random time during work hours
(30.days.ago.to_date..90.days.from_now.to_date).each do |date|
  rand(5).times do
    start = date.beginning_of_day + 8.hours + (rand(32) * 15).minutes
    Appointment.create :creator => User.find(:first, :order => 'rand()'),
                       :starts_at => start,
                       :ends_at => start + (rand(16) * 15).minutes,
                       :account_id => 1,
                       :name => "Meet with #{Faker::Name.name}"
  end
  rand(3).times do
    event = %w(birthday vacation sick trial).rand
    AllDay.create :creator => User.find(:first, :order => rand()),
                  :starts_at => date,
                  :ends_at => date + rand(4).days,
                  :account_id => 1,
                  :name => "#{Faker::Name.name}'s #{event}"
  end
  rand(4).times do
    CourtDate.create :creator => User.find(:first, :order => rand()),
                :starts_at => date,
                :ends_at => start + ((3..5).to_a.rand * 15).minutes,
                :account_id => 1,
                :name => "Help #{Faker::Name.name} with FinDec"
  end
  rand(4).times do
    Task.create :creator => User.find(:first, :order => rand()),
                :starts_at => date,
                :account_id => 1,
                :name => "Help #{Faker::Name.name} with FinDec"
  end
 
  rand(4).times do
    start = date.beginning_of_day + 8.hours + (rand(32) * 15).minutes
    Deadline.create :creator => User.find(:first, :order => rand()),
                    :starts_at => start,
                    :account_id => 1,
                    :name => "File docs for #{Faker::Name.name}"
  end
  
end