app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb in decidim-proposals-0.21.0 vs app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb in decidim-proposals-0.22.0
- old
+ new
@@ -15,21 +15,21 @@
# Ranking starts with 1.
# :total - an Integer representing the total number of ranked proposals.
#
# Examples:
# ranking_for(proposal, proposal_votes_count: :desc)
- # ranking_for(proposal, proposal_endorsements_count: :desc)
+ # ranking_for(proposal, endorsements_count: :desc)
def ranking_for(proposal, order = {})
siblings = Decidim::Proposals::Proposal.where(component: proposal.component)
ranked = siblings.order([order, id: :asc])
ranked_ids = ranked.pluck(:id)
{ ranking: ranked_ids.index(proposal.id) + 1, total: ranked_ids.count }
end
# Public: Gets the ranking for a given proposal, ordered by endorsements.
def endorsements_ranking_for(proposal)
- ranking_for(proposal, proposal_endorsements_count: :desc)
+ ranking_for(proposal, endorsements_count: :desc)
end
# Public: Gets the ranking for a given proposal, ordered by votes.
def votes_ranking_for(proposal)
ranking_for(proposal, proposal_votes_count: :desc)