diff --git a/db/seeds.rb b/db/seeds.rb index 6870a63e7..7ed50cd10 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -9,35 +9,43 @@ require 'config/environment' # Create seed user -User.create( :email => "a@a.com", :password => "aaaaaa", :profile => Profile.create( :first_name => "Robert", :last_name => "Grimm" )) +user = User.create( :email => "tom@joindiaspora.com", :password => "aaaaaa", :profile => Profile.create( :first_name => "Diaspora", :last_name => "Tom" )) + +names = [ ["George", "Washington"], + ["John", "Adams"], + ["Thomas", "Jefferson"], + ["James", "Madison"], + ["James", "Monroe"], + ["John Quincy", "Adams"], + ["Andrew", "Jackson"], + ["Martin Van", "Buren"], + ["William Henry","Harrison"], + ["John", "Tyler"], + ["James K." , "Polk"], + ["Zachary", "Taylor"], + ["Millard", "Fillmore"], + ["Franklin", "Pierce"], + ["James", "Buchanan"], + ["Abraham", "Lincoln"] + ] # Make friends -friend_one = Friend.create( :email => "babycakes@a.com", :url => "http://babycakes.joindiaspora.com/", :profile =>Profile.create( :first_name => "Baby", :last_name => "Cakes") ) -friend_two = Friend.create( :email => "mario@a.com", :url => "http://mario.joindiaspora.com/", :profile => Profile.create( :first_name => "Mario", :last_name => "Cakes") ) -friend_three = Friend.create( :email => "stuff@a.com", :url => "http://stuff.joindiaspora.com/", :profile => Profile.create( :first_name => "Stuff", :last_name => "Cakes") ) +(1..10).each { |n| + Friend.create( :email => "b#{n}@joindiaspora.com", :url => "http://b#{n}.joindiaspora.com/", :profile => Profile.create(:first_name => names[n-1][0], :last_name => names[n-1][1])) +} # Populate feed -StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => friend_one ) - -Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => friend_two ) - -StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => friend_two ) - -StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => friend_two ) - -StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => friend_three ) - -Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => friend_one ) -Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => friend_one ) - - -StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => friend_one ) -Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => friend_three ) - -StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => friend_two ) -StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => friend_three ) - -StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => friend_one ) - -StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => friend_two ) -StatusMessage.create(:message => "A cool, cool morning for once.", :person => friend_one ) +StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => user) +Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => user ) +StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => user, :created_at => Time.now-930) +StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => user, :created_at => Time.now-43990) +StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => user, :created_at => Time.now-4390) +Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => user, :created_at => Time.now-54390) +Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => user, :created_at => Time.now-3090) +StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => user, :created_at => Time.now-30900) +Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => user, :created_at => Time.now-9090) +StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => user, :created_at => Time.now-590000) +StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => user, :created_at => Time.now-503900) +StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => user, :created_at => Time.now-4400) +StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => user, :created_at => Time.now-400240) +StatusMessage.create(:message => "A cool, cool morning for once.", :person => user, :created_at => Time.now-150000) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb new file mode 100644 index 000000000..9e9a22ec3 --- /dev/null +++ b/db/seeds/backer.rb @@ -0,0 +1,38 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) +# Mayor.create(:name => 'Daley', :city => citie + +require 'config/environment' + + + +def create(backer_number, password) + names = [ ["George", "Washington"], + ["John", "Adams"], + ["Thomas", "Jefferson"], + ["James", "Madison"], + ["James", "Monroe"], + ["John Quincy", "Adams"], + ["Andrew", "Jackson"], + ["Martin Van", "Buren"], + ["William Henry","Harrison"], + ["John", "Tyler"], + ["James K." , "Polk"], + ["Zachary", "Taylor"], + ["Millard", "Fillmore"], + ["Franklin", "Pierce"], + ["James", "Buchanan"], + ["Abraham", "Lincoln"] + ] + + # Create seed user + user = User.create( :email => "b#{backer_number}@joindiaspora.com", :password => "#{password}", :profile => Profile.create( :first_name => names[backer_number][0], :last_name => names[backer_number][1] )) + + # Make friends with Diaspora Tom + Friend.create( :email => "tom@joindiaspora.com", :url => "http://tom.joindiaspora.com/", :profile => Profile.create(:first_name => "Diaspora", :last_name => "Tom")) +end + diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb new file mode 100644 index 000000000..7ed50cd10 --- /dev/null +++ b/db/seeds/tom.rb @@ -0,0 +1,51 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) +# Mayor.create(:name => 'Daley', :city => citie + +require 'config/environment' + +# Create seed user +user = User.create( :email => "tom@joindiaspora.com", :password => "aaaaaa", :profile => Profile.create( :first_name => "Diaspora", :last_name => "Tom" )) + +names = [ ["George", "Washington"], + ["John", "Adams"], + ["Thomas", "Jefferson"], + ["James", "Madison"], + ["James", "Monroe"], + ["John Quincy", "Adams"], + ["Andrew", "Jackson"], + ["Martin Van", "Buren"], + ["William Henry","Harrison"], + ["John", "Tyler"], + ["James K." , "Polk"], + ["Zachary", "Taylor"], + ["Millard", "Fillmore"], + ["Franklin", "Pierce"], + ["James", "Buchanan"], + ["Abraham", "Lincoln"] + ] + +# Make friends +(1..10).each { |n| + Friend.create( :email => "b#{n}@joindiaspora.com", :url => "http://b#{n}.joindiaspora.com/", :profile => Profile.create(:first_name => names[n-1][0], :last_name => names[n-1][1])) +} + +# Populate feed +StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => user) +Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => user ) +StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => user, :created_at => Time.now-930) +StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => user, :created_at => Time.now-43990) +StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => user, :created_at => Time.now-4390) +Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => user, :created_at => Time.now-54390) +Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => user, :created_at => Time.now-3090) +StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => user, :created_at => Time.now-30900) +Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => user, :created_at => Time.now-9090) +StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => user, :created_at => Time.now-590000) +StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => user, :created_at => Time.now-503900) +StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => user, :created_at => Time.now-4400) +StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => user, :created_at => Time.now-400240) +StatusMessage.create(:message => "A cool, cool morning for once.", :person => user, :created_at => Time.now-150000) diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index af9b5e476..6f1a47c2c 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -1,12 +1,23 @@ namespace :db do desc 'Seed the current RAILS_ENV database from db/seeds.rb' - task :seed do - require 'db/seeds' + namespace :seed do + task :tom do + puts "Seeding the database for #{Rails.env}..." + require 'db/seeds/tom' + end + task :backer, :num, :password do |t, args| + puts "Seeding the database for #{Rails.env}..." + require 'db/seeds/backer' + create( Integer(args.num), args.password ) + end end desc 'Delete the collections in the current RAILS_ENV database' - task :delete do + task :purge do require 'config/environment' + + puts "Purging the database for #{Rails.env}..." + # Specifiy what models to remove Post.delete_all Person.delete_all @@ -15,7 +26,10 @@ namespace :db do desc 'Purge and seed the current RAILS_ENV database using information from db/seeds.rb' task :reset do - Rake::Task['db:delete'].invoke - Rake::Task['db:seed'].invoke + + puts "Resetting the database for #{Rails.env}".upcase + Rake::Task['db:purge'].invoke + Rake::Task['db:seed:tom'].invoke + puts "Success!" end end