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
21 lines
478 B
Ruby
21 lines
478 B
Ruby
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
|