Use where.not instead of where(NOT IN)
This way we simplify the code a bit and reduce our usage of raw SQL.
This commit is contained in:
@@ -158,7 +158,7 @@ class ProposalsController < ApplicationController
|
|||||||
.sort_by_confidence_score.limit(Setting["featured_proposals_number"])
|
.sort_by_confidence_score.limit(Setting["featured_proposals_number"])
|
||||||
if @featured_proposals.present?
|
if @featured_proposals.present?
|
||||||
set_featured_proposal_votes(@featured_proposals)
|
set_featured_proposal_votes(@featured_proposals)
|
||||||
@resources = @resources.where("proposals.id NOT IN (?)", @featured_proposals.map(&:id))
|
@resources = @resources.where.not(id: @featured_proposals)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class UsersController < ApplicationController
|
|||||||
disabled_commentables << "Debate" unless Setting["process.debates"]
|
disabled_commentables << "Debate" unless Setting["process.debates"]
|
||||||
disabled_commentables << "Budget::Investment" unless Setting["process.budgets"]
|
disabled_commentables << "Budget::Investment" unless Setting["process.budgets"]
|
||||||
if disabled_commentables.present?
|
if disabled_commentables.present?
|
||||||
all_user_comments.where("commentable_type NOT IN (?)", disabled_commentables)
|
all_user_comments.where.not(commentable_type: disabled_commentables)
|
||||||
else
|
else
|
||||||
all_user_comments
|
all_user_comments
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
section "Voting Debates, Proposals & Comments" do
|
section "Voting Debates, Proposals & Comments" do
|
||||||
not_org_users = User.where(["users.id NOT IN(?)", User.organizations.pluck(:id)])
|
not_org_users = User.where.not(id: User.organizations)
|
||||||
100.times do
|
100.times do
|
||||||
voter = not_org_users.level_two_or_three_verified.all.sample
|
voter = not_org_users.level_two_or_three_verified.all.sample
|
||||||
vote = [true, false].sample
|
vote = [true, false].sample
|
||||||
|
|||||||
@@ -45,9 +45,8 @@ class UserSegments
|
|||||||
|
|
||||||
def self.not_supported_on_current_budget
|
def self.not_supported_on_current_budget
|
||||||
author_ids(
|
author_ids(
|
||||||
User.where(
|
User.where.not(
|
||||||
"id NOT IN (?)",
|
id: Vote.select(:voter_id).where(votable: current_budget_investments).distinct
|
||||||
Vote.select(:voter_id).where(votable: current_budget_investments).distinct
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user