diaspora/db/seeds.rb
Jonne Haß 79a79d65d6 Bye Resque. Ohai Sidekiq.
* Dropped all references to Resque
* Moved all jobs under app/workers since that's the Sidekiq convention
* Renamed Jobs module to Worker to match new location
* Adapted all jobs to Sidekiq
* Replaced all enqueue calls with perform_async
* Dropped Resque hacks from specs and features, replaced with
  sidekig/testing in RSpec and sidekig/testing/inline in Cucumber
* Updated scripts to start a Sidekiq server
* Inline Sidekiq sinatra app
* Let Sidekiq create the actual Redis instance
* Workaround already initialized constant warnings in service models
* Resolved ToDo in one job definition by creating proper exception clases
  for some errors in receiving posts
* Added sidekiq section to configuration to make it completly
  configurable to the user
* Add Sidekiq middleware for clean backtraces
* Delay HttpMulti retry to give offline pods a chance to come back up
* Do not retry on GUID already taken and alike errors
* Be graceful about deleted posts in GatherOEmbedData
2013-03-21 23:39:07 +01:00

75 lines
2.6 KiB
Ruby

# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
# 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 Rails.root.join('config', 'environment')
require 'factory_girl_rails'
require Rails.root.join('spec', 'helper_methods')
include HelperMethods
alice = FactoryGirl.create(:user_with_aspect, :username => "alice", :password => 'evankorth')
bob = FactoryGirl.create(:user_with_aspect, :username => "bob", :password => 'evankorth')
eve = FactoryGirl.create(:user_with_aspect, :username => "eve", :password => 'evankorth')
def url_hash(name)
image_url = "/assets/user/#{name}.jpg"
{
:image_url => image_url,
:image_url_small => image_url,
:image_url_medium => image_url
}
end
print "Creating seeded users... "
alice.person.profile.update_attributes({:first_name => "Alice", :last_name => "Smith"}.merge(url_hash('uma')))
bob.person.profile.update_attributes({:first_name => "Bob", :last_name => "Grimm"}.merge(url_hash('wolf')))
eve.person.profile.update_attributes({:first_name => "Eve", :last_name => "Doe"}.merge(url_hash('angela')))
puts "done!"
print "Connecting users... "
connect_users(bob, bob.aspects.first, alice, alice.aspects.first)
connect_users(bob, bob.aspects.first, eve, eve.aspects.first)
puts "done!"
print "making Bob an admin... "
Role.add_admin(bob.person)
puts "done!"
require 'sidekiq/testing/inline'
require Rails.root.join('spec', 'support', 'user_methods')
print "Seeding post data..."
time_interval = 1000
(1..25).each do |n|
[alice, bob, eve].each do |u|
print '.'
if(n%3==1)
post = u.post :status_message, :text => "#{u.username} - #{n} - #seeded", :to => u.aspects.first.id
elsif(n%3==2)
post = u.post(:reshare, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => 'all')
else
post = FactoryGirl.create(:activity_streams_photo, :public => true, :author => u.person)
u.add_to_streams(post, u.aspects)
end
post.created_at = post.created_at - time_interval
post.updated_at = post.updated_at - time_interval
post.save
time_interval += 1000
end
end
puts " done!"
puts "Successfully seeded the db with users eve, bob, and alice (password: 'evankorth')"
puts ""