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
a608560a
Commit
a608560a
authored
Aug 30, 2019
by
manojmj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Application Statistics API
This change implements Application Statistics API
parent
d63de244
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
0 deletions
+68
-0
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/entities.rb
lib/api/entities.rb
+49
-0
lib/api/statistics.rb
lib/api/statistics.rb
+18
-0
No files found.
lib/api/api.rb
View file @
a608560a
...
...
@@ -161,6 +161,7 @@ module API
mount
::
API
::
Settings
mount
::
API
::
SidekiqMetrics
mount
::
API
::
Snippets
mount
::
API
::
Statistics
mount
::
API
::
Submodules
mount
::
API
::
Subscriptions
mount
::
API
::
Suggestions
...
...
lib/api/entities.rb
View file @
a608560a
...
...
@@ -1167,6 +1167,55 @@ module API
expose
:message
,
:starts_at
,
:ends_at
,
:color
,
:font
end
class
ApplicationStatistics
<
Grape
::
Entity
include
ActionView
::
Helpers
::
NumberHelper
include
CountHelper
expose
:forks
do
|
counts
|
approximate_fork_count_with_delimiters
(
counts
)
end
expose
:issues
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Issue
)
end
expose
:merge_requests
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
MergeRequest
)
end
expose
:notes
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Note
)
end
expose
:snippets
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Snippet
)
end
expose
:ssh_keys
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Key
)
end
expose
:milestones
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Milestone
)
end
expose
:users
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
User
)
end
expose
:projects
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Project
)
end
expose
:groups
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Group
)
end
expose
:active_users
do
|
_
|
number_with_delimiter
(
::
User
.
active
.
count
)
end
end
class
ApplicationSetting
<
Grape
::
Entity
def
self
.
exposed_attributes
attributes
=
::
ApplicationSettingsHelper
.
visible_attributes
...
...
lib/api/statistics.rb
0 → 100644
View file @
a608560a
# frozen_string_literal: true
module
API
class
Statistics
<
Grape
::
API
before
{
authenticated_as_admin!
}
COUNTED_ITEMS
=
[
Project
,
User
,
Group
,
ForkNetworkMember
,
ForkNetwork
,
Issue
,
MergeRequest
,
Note
,
Snippet
,
Key
,
Milestone
].
freeze
desc
'Get the current application statistics'
do
success
Entities
::
ApplicationStatistics
end
get
"application/statistics"
do
counts
=
Gitlab
::
Database
::
Count
.
approximate_counts
(
COUNTED_ITEMS
)
present
counts
,
with:
Entities
::
ApplicationStatistics
end
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