gitlab-org--gitlab-foss/app/helpers/dashboard_helper.rb

77 lines
1.7 KiB
Ruby
Raw Normal View History

2012-11-21 00:24:05 -05:00
module DashboardHelper
def filter_path(entity, options={})
2012-11-26 23:29:11 -05:00
exist_opts = {
state: params[:state],
scope: params[:scope],
2012-11-26 23:29:11 -05:00
project_id: params[:project_id],
}
options = exist_opts.merge(options)
path = request.path
path << "?#{options.to_param}"
path
2012-11-21 00:24:05 -05:00
end
2012-11-21 01:14:05 -05:00
def entities_per_project(project, entity)
case entity.to_sym
when :issue then @issues.where(project_id: project.id)
when :merge_request then @merge_requests.where(target_project_id: project.id)
else
[]
end.count
2012-11-21 01:14:05 -05:00
end
def projects_dashboard_filter_path(options={})
exist_opts = {
sort: params[:sort],
scope: params[:scope],
group: params[:group],
}
options = exist_opts.merge(options)
path = request.path
path << "?#{options.to_param}"
path
end
def assigned_entities_count(current_user, entity, scope = nil)
items = current_user.send("assigned_" + entity.pluralize).opened
if scope.kind_of?(Group)
items = items.of_group(scope)
elsif scope.kind_of?(Project)
items = items.of_projects(scope)
end
items.count
end
def authored_entities_count(current_user, entity, scope = nil)
items = current_user.send(entity.pluralize).opened
if scope.kind_of?(Group)
items = items.of_group(scope)
elsif scope.kind_of?(Project)
items = items.of_projects(scope)
end
items.count
end
def authorized_entities_count(current_user, entity, scope = nil)
items = entity.classify.constantize.opened
if scope.kind_of?(Group)
items = items.of_group(scope)
elsif scope.kind_of?(Project)
items = items.of_projects(scope)
else
items = items.of_projects(current_user.authorized_projects)
end
items.count
end
2012-11-21 00:24:05 -05:00
end