diff options
author | Manoj MJ <mmj@gitlab.com> | 2019-09-09 03:38:42 +0000 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2019-09-09 03:38:42 +0000 |
commit | b041321a355b507cd9329e80935e960c2b9114eb (patch) | |
tree | 5013fa7c76955750a869b5a071a1d8d8cecd9686 /lib/api/entities.rb | |
parent | e3763f9cb60e7f1ddf8c40ddc4bf05747e944f9b (diff) | |
download | gitlab-ce-b041321a355b507cd9329e80935e960c2b9114eb.tar.gz |
Application Statistics API
This change implements Application
Statistics API
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r-- | lib/api/entities.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index f7cd6d35854..c9b3483acaf 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1169,6 +1169,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 |