Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
da99560e
Commit
da99560e
authored
Oct 02, 2014
by
Ciro Santilli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor dashboard helper methods.
parent
b0349915
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
21 deletions
+12
-21
app/helpers/dashboard_helper.rb
app/helpers/dashboard_helper.rb
+12
-21
No files found.
app/helpers/dashboard_helper.rb
View file @
da99560e
...
...
@@ -37,40 +37,31 @@ module DashboardHelper
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
items
=
current_user
.
send
(
'assigned_'
+
entity
.
pluralize
)
get_count
(
items
,
scope
)
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
items
=
current_user
.
send
(
entity
.
pluralize
)
get_count
(
items
,
scope
)
end
def
authorized_entities_count
(
current_user
,
entity
,
scope
=
nil
)
items
=
entity
.
classify
.
constantize
.
opened
items
=
entity
.
classify
.
constantize
get_count
(
items
,
scope
,
true
,
current_user
)
end
protected
def
get_count
(
items
,
scope
,
get_authorized
=
false
,
current_user
=
nil
)
items
=
items
.
opened
if
scope
.
kind_of?
(
Group
)
items
=
items
.
of_group
(
scope
)
elsif
scope
.
kind_of?
(
Project
)
items
=
items
.
of_projects
(
scope
)
els
e
els
if
get_authorized
items
=
items
.
of_projects
(
current_user
.
authorized_projects
)
end
items
.
count
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment