The new CSV report was more configurable and could work on proposals,
processes and comments. However, it had several issues.
In the public area, by default it generated a blank file.
In the admin section, the report was hard to configure and it generated
a file with less quality than the old system.
So until we improve this system, we're bringing back the old investment
CSV exporter.
This commit reverts most of commit 9d1ca3bf.
37 lines
1.0 KiB
Ruby
37 lines
1.0 KiB
Ruby
module Budgets
|
|
class ExecutionsController < ApplicationController
|
|
before_action :load_budget
|
|
|
|
load_and_authorize_resource :budget
|
|
|
|
def show
|
|
authorize! :read_executions, @budget
|
|
@statuses = Milestone::Status.all
|
|
@investments_by_heading = investments_by_heading_ordered_alphabetically.to_h
|
|
end
|
|
|
|
private
|
|
|
|
def investments_by_heading
|
|
base = @budget.investments.winners
|
|
base = base.joins(milestones: :translations).includes(:milestones)
|
|
base = base.tagged_with(params[:milestone_tag]) if params[:milestone_tag].present?
|
|
|
|
if params[:status].present?
|
|
base = base.with_milestone_status_id(params[:status])
|
|
base.uniq.group_by(&:heading)
|
|
else
|
|
base.distinct.group_by(&:heading)
|
|
end
|
|
end
|
|
|
|
def load_budget
|
|
@budget = Budget.find_by_slug_or_id params[:budget_id]
|
|
end
|
|
|
|
def investments_by_heading_ordered_alphabetically
|
|
investments_by_heading.sort { |a, b| a[0].name <=> b[0].name }
|
|
end
|
|
end
|
|
end
|