Adds budget dev_seeds
This commit is contained in:
@@ -149,7 +149,7 @@ tags = Faker::Lorem.words(25)
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
proposal = Proposal.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
question: Faker::Lorem.sentence(3),
|
||||
question: Faker::Lorem.sentence(4),
|
||||
summary: Faker::Lorem.sentence(3),
|
||||
responsible_name: Faker::Name.name,
|
||||
external_url: Faker::Internet.url,
|
||||
@@ -168,7 +168,7 @@ tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
proposal = Proposal.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
question: Faker::Lorem.sentence(3),
|
||||
question: Faker::Lorem.sentence(4),
|
||||
summary: Faker::Lorem.sentence(3),
|
||||
responsible_name: Faker::Name.name,
|
||||
external_url: Faker::Internet.url,
|
||||
@@ -266,7 +266,7 @@ puts "Creating Spending Proposals"
|
||||
|
||||
tags = Faker::Lorem.words(10)
|
||||
|
||||
(1..60).each do |i|
|
||||
(1..10).each do |i|
|
||||
geozone = Geozone.reorder("RANDOM()").first
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
@@ -294,6 +294,58 @@ puts "Creating Valuation Assignments"
|
||||
SpendingProposal.reorder("RANDOM()").first.valuators << valuator.valuator
|
||||
end
|
||||
|
||||
|
||||
puts "Creating Budgets"
|
||||
|
||||
(1..10).each do |i|
|
||||
budget = Budget.create!(name: (Date.today.year - 10 + i).to_s,
|
||||
description: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
|
||||
price: rand(1 .. 100) * 100000,
|
||||
phase: %w{on_hold accepting selecting balloting finished}.sample,
|
||||
valuating: [false, true].sample)
|
||||
puts budget.name
|
||||
puts " "
|
||||
geozones = Geozone.reorder("RANDOM()").limit(10)
|
||||
geozones.each do |geozone|
|
||||
heading = budget.headings.create!(name: geozone.name,
|
||||
geozone: geozone,
|
||||
price: rand(1 .. 100) * 10000)
|
||||
budget.headings << heading
|
||||
print "heading.name "
|
||||
end
|
||||
puts ""
|
||||
end
|
||||
|
||||
|
||||
puts "Creating Investments"
|
||||
tags = Faker::Lorem.words(10)
|
||||
(1..60).each do |i|
|
||||
heading = [Budget::Heading.reorder("RANDOM()").first, nil].sample
|
||||
|
||||
investment = Budget::Investment.create!(
|
||||
author: User.reorder("RANDOM()").first,
|
||||
heading: heading,
|
||||
budget: heading.try(:budget) || Budget.reorder("RANDOM()").first,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
external_url: Faker::Internet.url,
|
||||
description: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
|
||||
created_at: rand((Time.now - 1.week) .. Time.now),
|
||||
feasibility: %w{undecided feasible unfeasible}.sample,
|
||||
unfeasibility_explanation: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
|
||||
valuation_finished: [false, true].sample,
|
||||
tag_list: tags.sample(3).join(','),
|
||||
price: rand(1 .. 100) * 1000000,
|
||||
terms_of_service: "1")
|
||||
puts " #{investment.title}"
|
||||
end
|
||||
|
||||
puts "Creating Valuation Assignments"
|
||||
|
||||
(1..17).to_a.sample.times do
|
||||
Budget::Investment.reorder("RANDOM()").first.valuators << valuator.valuator
|
||||
end
|
||||
|
||||
|
||||
puts "Creating Legislation"
|
||||
|
||||
Legislation.create!(title: 'Participatory Democracy', body: 'In order to achieve...')
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddBudgetInvestmentsCountToTags < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :tags, "budget/investments_count", :integer, default: 0
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160524144005) do
|
||||
ActiveRecord::Schema.define(version: 20160531102008) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -425,6 +425,7 @@ ActiveRecord::Schema.define(version: 20160524144005) do
|
||||
t.integer "proposals_count", default: 0
|
||||
t.integer "spending_proposals_count", default: 0
|
||||
t.string "kind"
|
||||
t.integer "budget/investments_count", default: 0
|
||||
end
|
||||
|
||||
add_index "tags", ["debates_count"], name: "index_tags_on_debates_count", using: :btree
|
||||
|
||||
Reference in New Issue
Block a user