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

@@ -1,4 +1,4 @@
<% voted_classes = css_classes_for_vote(legislation_proposal_votes, proposal) %>
<% voted_classes = css_classes_for_vote(proposal) %>
<div class="votes">
<% if proposal.process.proposals_phase.open? %>
<div class="in-favor inline-block">
@@ -64,7 +64,7 @@
</div>
<% end %>
<% if voted_for?(legislation_proposal_votes, proposal) && setting["twitter_handle"] %>
<% if current_user&.voted_as_when_voted_for(proposal) && setting["twitter_handle"] %>
<div class="share-supported">
<%= render "shared/social_share",
title: proposal.title,

View File

@@ -1,9 +1,8 @@
class Legislation::Proposals::VotesComponent < ApplicationComponent
attr_reader :proposal, :legislation_proposal_votes
delegate :css_classes_for_vote, :current_user, :link_to_verify_account, :user_signed_in?, :voted_for?, :votes_percentage, to: :helpers
attr_reader :proposal
delegate :css_classes_for_vote, :current_user, :link_to_verify_account, :user_signed_in?, :votes_percentage, to: :helpers
def initialize(proposal, legislation_proposal_votes:)
def initialize(proposal)
@proposal = proposal
@legislation_proposal_votes = legislation_proposal_votes
end
end