From cd148dfbf09658940394b77e4178740e5212fb90 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 18:44:24 +0200 Subject: [PATCH] adds recounts and results to dev seeds --- db/dev_seeds.rb | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 18bfe0dcb..8c09923d8 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -640,6 +640,49 @@ print "Creating Poll Voters" Poll::Voter.create(poll: poll, user: user) end +puts " ✅" +print "Creating Poll Recounts" + +Poll.all.each do |poll| + poll.booth_assignments.each do |booth_assignment| + officer_assignment = poll.officer_assignments.first + author = Poll::Officer.first.user + + Poll::Recount.create!(officer_assignment: officer_assignment, + booth_assignment: booth_assignment, + author: author, + date: poll.ends_at, + white_amount: rand(0..10), + null_amount: rand(0..10), + total_amount: rand(100..9999), + origin: "booth") + end +end + +puts " ✅" +print "Creating Poll Results" + +Poll.all.each do |poll| + poll.booth_assignments.each do |booth_assignment| + officer_assignment = poll.officer_assignments.first + author = Poll::Officer.first.user + + poll.questions.each do |question| + question.question_answers.each do |answer| + Poll::PartialResult.create!(officer_assignment: officer_assignment, + booth_assignment: booth_assignment, + date: Date.current, + question: question, + answer: answer.title, + author: author, + amount: rand(999), + origin: "booth") + end + end + end + +end + puts " ✅" print "Creating legislation processes"