dashboard_helper.rb 686 字节
Newer Older
D
Dmitriy Zaporozhets 已提交
1 2
module DashboardHelper
  def dashboard_filter_path(entity, options={})
3 4 5 6 7 8 9
    exist_opts = {
      status: params[:status],
      project_id: params[:project_id],
    }

    options = exist_opts.merge(options)

D
Dmitriy Zaporozhets 已提交
10 11
    case entity
    when 'issue' then
D
Dmitriy Zaporozhets 已提交
12
      issues_dashboard_path(options)
D
Dmitriy Zaporozhets 已提交
13
    when 'merge_request'
D
Dmitriy Zaporozhets 已提交
14
      merge_requests_dashboard_path(options)
D
Dmitriy Zaporozhets 已提交
15 16
    end
  end
D
Dmitriy Zaporozhets 已提交
17 18

  def entities_per_project project, entity
19 20 21 22 23 24 25 26 27 28 29
    items = project.items_for(entity)

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

30
    items.cared(current_user).count
D
Dmitriy Zaporozhets 已提交
31
  end
D
Dmitriy Zaporozhets 已提交
32
end