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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
187117f2
Commit
187117f2
authored
Feb 14, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Calculate amount of users per role by max access
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
9281cf89
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
0 deletions
+30
-0
app/controllers/admin/dashboard_controller.rb
app/controllers/admin/dashboard_controller.rb
+4
-0
app/models/project_authorization.rb
app/models/project_authorization.rb
+17
-0
app/views/admin/dashboard/index.html.haml
app/views/admin/dashboard/index.html.haml
+1
-0
ee/app/views/admin/dashboard/_roles_stats.html.haml
ee/app/views/admin/dashboard/_roles_stats.html.haml
+8
-0
No files found.
app/controllers/admin/dashboard_controller.rb
View file @
187117f2
...
@@ -4,5 +4,9 @@ class Admin::DashboardController < Admin::ApplicationController
...
@@ -4,5 +4,9 @@ class Admin::DashboardController < Admin::ApplicationController
@users
=
User
.
order_id_desc
.
limit
(
10
)
@users
=
User
.
order_id_desc
.
limit
(
10
)
@groups
=
Group
.
order_id_desc
.
with_route
.
limit
(
10
)
@groups
=
Group
.
order_id_desc
.
with_route
.
limit
(
10
)
@license
=
License
.
current
@license
=
License
.
current
# EE only
@admin_count
=
User
.
admins
.
count
@roles_count
=
ProjectAuthorization
.
roles_stats
end
end
end
end
app/models/project_authorization.rb
View file @
187117f2
...
@@ -24,4 +24,21 @@ class ProjectAuthorization < ActiveRecord::Base
...
@@ -24,4 +24,21 @@ class ProjectAuthorization < ActiveRecord::Base
EOF
EOF
end
end
end
end
def
self
.
roles_stats
connection
.
execute
<<-
EOF
.
strip_heredoc
SELECT CASE max(access_level)
WHEN 10 THEN 'guest'
WHEN 20 THEN 'reporter'
WHEN 30 THEN 'developer'
WHEN 40 THEN 'master'
WHEN 50 THEN 'owner'
ELSE 'unknown' END
AS kind,
count(DISTINCT user_id) AS amount
FROM
#{
table_name
}
GROUP BY access_level
ORDER BY amount DESC;
EOF
end
end
end
app/views/admin/dashboard/index.html.haml
View file @
187117f2
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
%div
{
class:
container_class
}
%div
{
class:
container_class
}
-
if
@license
-
if
@license
=
render
"admin/licenses/breakdown"
,
license:
@license
=
render
"admin/licenses/breakdown"
,
license:
@license
=
render
"admin/dashboard/roles_stats"
.admin-dashboard.prepend-top-default
.admin-dashboard.prepend-top-default
.row
.row
...
...
ee/app/views/admin/dashboard/_roles_stats.html.haml
0 → 100644
View file @
187117f2
%div
%p
Admin users:
#{
@admin_count
}
-
@roles_count
.
each
do
|
row
|
%p
Users with max
#{
row
[
'kind'
]
}
access level:
%strong
=
row
[
'amount'
]
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