Files
grecia/app/helpers/budget_executions_helper.rb
Javi Martín 958d373247 Fix duplicate records in investments by tag
When an investment had been assigned a user tag and a valuation tag with
the same name, it appeared twice when filtering by tag.

This is because by design, in order to provide compatibility with scopes
using "select" or "distinct", the method `tagged_with` doesn't select
unique records.

Forcing the query to return unique records solves the issue.
2020-04-09 21:09:28 +02:00

17 lines
503 B
Ruby

module BudgetExecutionsHelper
def filters_select_counts(status)
@budget.investments.winners.with_milestone_status_id(status).count
end
def options_for_milestone_tags
@budget.investments_milestone_tags.map do |tag|
["#{tag} (#{@budget.investments.winners.by_tag(tag).count})", tag]
end
end
def first_milestone_with_image(investment)
investment.milestones.order_by_publication_date
.select { |milestone| milestone.image.present? }.last
end
end