Remove votes query optimizations

Just like we did in commit 0214184b2d for investments, we're removing
some possible optimizations (we don't have any benchmarks proving they
affect performance at all) in order to simplify the code.

The investement votes component `delegate` code was accidentally left
but isn't used since commit 0214184b2, so we're removing it now that
we're removing the `voted_for?` helper method.
This commit is contained in:
Javi Martín
2021-09-28 19:31:57 +02:00
parent 78f372fd0b
commit b98244afd9
29 changed files with 39 additions and 123 deletions

View File

@@ -58,7 +58,6 @@ class ProposalsController < ApplicationController
def vote
@follow = Follow.find_or_create_by!(user: current_user, followable: @proposal)
@proposal.register_vote(current_user, "yes")
set_proposal_votes(@proposal)
end
def retire
@@ -75,7 +74,6 @@ class ProposalsController < ApplicationController
def vote_featured
@follow = Follow.find_or_create_by!(user: current_user, followable: @proposal)
@proposal.register_vote(current_user, "yes")
set_featured_proposal_votes(@proposal)
end
def summary
@@ -118,10 +116,6 @@ class ProposalsController < ApplicationController
Proposal
end
def set_featured_proposal_votes(proposals)
@featured_proposals_votes = current_user ? current_user.proposal_votes(proposals) : {}
end
def discard_draft
@resources = @resources.published
end
@@ -156,7 +150,6 @@ class ProposalsController < ApplicationController
@featured_proposals = Proposal.not_archived.unsuccessful
.sort_by_confidence_score.limit(Setting["featured_proposals_number"])
if @featured_proposals.present?
set_featured_proposal_votes(@featured_proposals)
@resources = @resources.where.not(id: @featured_proposals)
end
end