Restore filtering investments by milestone status query
This commit makes 3 changes: 1. Extracts a query into a helper for clarity and DRYness 2. Adds a `.where` clause to filter investments based on their (current) milestone status 3. Fixes a bug where investments would be rendered as many times as milestones associated to an investment
This commit is contained in:
20
app/helpers/budget_executions_helper.rb
Normal file
20
app/helpers/budget_executions_helper.rb
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
module BudgetExecutionsHelper
|
||||||
|
|
||||||
|
def winner_investments(heading)
|
||||||
|
if params[:status].present?
|
||||||
|
heading.investments
|
||||||
|
.selected
|
||||||
|
.sort_by_ballots
|
||||||
|
.joins(:milestones)
|
||||||
|
.distinct
|
||||||
|
.where('budget_investment_milestones.status_id = ?', params[:status])
|
||||||
|
else
|
||||||
|
heading.investments
|
||||||
|
.selected
|
||||||
|
.sort_by_ballots
|
||||||
|
.joins(:milestones)
|
||||||
|
.distinct
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<%= heading.name %>
|
<%= heading.name %>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="row" data-equalizer-on="medium" data-equalizer>
|
<div class="row" data-equalizer-on="medium" data-equalizer>
|
||||||
<% heading.investments.selected.sort_by_ballots.joins(:milestones).each do |investment| %>
|
<% winner_investments(heading).each do |investment| %>
|
||||||
<div class="small-12 medium-6 large-4 column end margin-bottom">
|
<div class="small-12 medium-6 large-4 column end margin-bottom">
|
||||||
<div class="budget-execution">
|
<div class="budget-execution">
|
||||||
<%= link_to budget_investment_path(@budget, investment, anchor: "tab-milestones"), data: { 'equalizer-watch': true } do %>
|
<%= link_to budget_investment_path(@budget, investment, anchor: "tab-milestones"), data: { 'equalizer-watch': true } do %>
|
||||||
|
|||||||
Reference in New Issue
Block a user