Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-10 18:54:31 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-10 18:54:31 +0400
commitcff1758486675cb41ad959c8eefde11b016c0571 (patch)
treec5c2cd6539e9babc4bb8ed8ab98bedba88b94128 /app/helpers/dashboard_helper.rb
parenta338954c331ed451c7b7dd39b28b9649dfca26ba (diff)
Show counters in sidebar filter in same way like we did for projects page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/helpers/dashboard_helper.rb')
-rw-r--r--app/helpers/dashboard_helper.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb
index d5712ab3374..c4e33e3308f 100644
--- a/app/helpers/dashboard_helper.rb
+++ b/app/helpers/dashboard_helper.rb
@@ -35,4 +35,42 @@ module DashboardHelper
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
end