Sha256: c77e8a4804ab72336e820d66968ff07d2f6461a53ee81f3538e761454e3c447a
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
namespace :db do namespace :populate do desc "Create populate data with documents" task :create => :create_links desc "Add links to populate data" task :create_links => :read_environment do puts 'Links population' links_start = Time.now 50.times do updated = Time.at(rand(Time.now.to_i)) author = Actor.all[rand(Actor.all.size)] owner = author user_author = ( author.subject_type == "User" ? author : author.user_author ) d = Link.create! :title => Forgery::LoremIpsum.words(1+rand(4),:random => true), :description => Forgery::LoremIpsum.sentences(1+rand(4), :random => true), :url => "http://#{ Forgery::Internet.domain_name }", :created_at => Time.at(rand(updated.to_i)), :updated_at => updated, :author_id => author.id, :owner_id => owner.id, :user_author_id => user_author.id, :_relation_ids => [Relation::Public.instance.id] d.save! end links_end = Time.now puts ' -> ' + (links_end - links_start).round(4).to_s + 's' end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
social_stream-0.26.0 | linkser/lib/tasks/db/populate_links.rake |
social_stream-linkser-0.11.0 | lib/tasks/db/populate_links.rake |