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.
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
section "Flagging Debates & Comments" do
|
||||
40.times do
|
||||
debate = Debate.sample
|
||||
flagger = User.where.not(id: debate.author_id).sample
|
||||
flagger = User.excluding(debate.author).sample
|
||||
Flag.flag(flagger, debate)
|
||||
end
|
||||
|
||||
40.times do
|
||||
comment = Comment.sample
|
||||
flagger = User.where.not(id: comment.user_id).sample
|
||||
flagger = User.excluding(comment.user).sample
|
||||
Flag.flag(flagger, comment)
|
||||
end
|
||||
|
||||
40.times do
|
||||
proposal = Proposal.sample
|
||||
flagger = User.where.not(id: proposal.author_id).sample
|
||||
flagger = User.excluding(proposal.author).sample
|
||||
Flag.flag(flagger, proposal)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
section "Voting Debates, Proposals & Comments" do
|
||||
not_org_users = User.where.not(id: User.organizations)
|
||||
not_org_users = User.excluding(User.organizations)
|
||||
100.times do
|
||||
voter = not_org_users.level_two_or_three_verified.sample
|
||||
vote = [true, false].sample
|
||||
|
||||
Reference in New Issue
Block a user