Files
nairobi/db/dev_seeds/flags.rb
Javi Martín 38ad65605e Use excluding instead of where.not(id:
This method was added in Rails 7.0 and makes the code slihgtly more
readable.

The downside is that it generates two queries instead of one, so it
might generate some confusion when debugging SQL queries. Its impact on
performance is probably negligible.
2024-07-22 18:35:35 +02:00

26 lines
657 B
Ruby

section "Flagging Debates & Comments" do
40.times do
debate = Debate.sample
flagger = User.excluding(debate.author).sample
Flag.flag(flagger, debate)
end
40.times do
comment = Comment.sample
flagger = User.excluding(comment.user).sample
Flag.flag(flagger, comment)
end
40.times do
proposal = Proposal.sample
flagger = User.excluding(proposal.author).sample
Flag.flag(flagger, proposal)
end
end
section "Ignoring flags in Debates, comments & proposals" do
Debate.flagged.sample(10).each(&:ignore_flag)
Comment.flagged.sample(30).each(&:ignore_flag)
Proposal.flagged.sample(10).each(&:ignore_flag)
end