summaryrefslogtreecommitdiff
path: root/app/helpers/dashboard_helper.rb
blob: e3be07c9fe0a8da06e5bc6e150cd720c4dd2ee2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module DashboardHelper
  def dashboard_filter_path(entity, options={})
    exist_opts = {
      status: params[:status],
      project_id: params[:project_id],
    }

    options = exist_opts.merge(options)

    case entity
    when 'issue' then
      issues_dashboard_path(options)
    when 'merge_request'
      merge_requests_dashboard_path(options)
    end
  end

  def entities_per_project project, entity
    items = project.items_for(entity)

    items = case params[:status]
            when 'closed'
              items.closed
            when 'all'
              items
            else
              items.opened
            end

    items.cared(current_user).count
  end
end