Files
grecia/db/dev_seeds/votes.rb
Javi Martín 1b34c061bb Use where.not instead of where(NOT IN)
This way we simplify the code a bit and reduce our usage of raw SQL.
2020-07-14 12:32:12 +02:00

23 lines
650 B
Ruby

section "Voting Debates, Proposals & Comments" do
not_org_users = User.where.not(id: User.organizations)
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