Files
nairobi/db/dev_seeds/votes.rb
Bertocq 54e6c5fc5c Split dev_seeds into individual files for sections
Why:

Its a really huge script, and conflicts are hard to resolve on forks,
with indivudal scripts its easier to make custom changes.

How:

Following @mariacheca example using require_relative and a file under
the db/dev_seeds/ folder
2018-02-22 11:04:47 +01:00

23 lines
677 B
Ruby

section "Voting Debates, Proposals & Comments" do
not_org_users = User.where(['users.id NOT IN(?)', User.organizations.pluck(:id)])
100.times do
voter = not_org_users.level_two_or_three_verified.all.sample
vote = [true, false].sample
debate = Debate.all.sample
debate.vote_by(voter: voter, vote: vote)
end
100.times do
voter = not_org_users.all.sample
vote = [true, false].sample
comment = Comment.all.sample
comment.vote_by(voter: voter, vote: vote)
end
100.times do
voter = not_org_users.level_two_or_three_verified.all.sample
proposal = Proposal.all.sample
proposal.vote_by(voter: voter, vote: true)
end
end