2020-03-09 13:42:32 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class ApplicationStatistics < Grape::Entity
|
|
|
|
include ActionView::Helpers::NumberHelper
|
|
|
|
include CountHelper
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :forks,
|
|
|
|
documentation: { type: 'integer', example: 6, desc: 'Approximate number of repo forks' } do |counts|
|
2020-03-09 13:42:32 +05:30
|
|
|
approximate_fork_count_with_delimiters(counts)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :issues,
|
|
|
|
documentation: { type: 'integer', example: 121, desc: 'Approximate number of issues' } do |counts|
|
2020-03-09 13:42:32 +05:30
|
|
|
approximate_count_with_delimiters(counts, ::Issue)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :merge_requests,
|
|
|
|
documentation: { type: 'integer', example: 49, desc: 'Approximate number of merge requests' } do |counts|
|
2020-03-09 13:42:32 +05:30
|
|
|
approximate_count_with_delimiters(counts, ::MergeRequest)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :notes,
|
|
|
|
documentation: { type: 'integer', example: 6, desc: 'Approximate number of notes' } do |counts|
|
2020-03-09 13:42:32 +05:30
|
|
|
approximate_count_with_delimiters(counts, ::Note)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :snippets,
|
|
|
|
documentation: { type: 'integer', example: 4, desc: 'Approximate number of snippets' } do |counts|
|
2020-03-09 13:42:32 +05:30
|
|
|
approximate_count_with_delimiters(counts, ::Snippet)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :ssh_keys,
|
|
|
|
documentation: { type: 'integer', example: 11, desc: 'Approximate number of SSH keys' } do |counts|
|
2020-03-09 13:42:32 +05:30
|
|
|
approximate_count_with_delimiters(counts, ::Key)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :milestones,
|
|
|
|
documentation: { type: 'integer', example: 3, desc: 'Approximate number of milestones' } do |counts|
|
2020-03-09 13:42:32 +05:30
|
|
|
approximate_count_with_delimiters(counts, ::Milestone)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :users, documentation: { type: 'integer', example: 22, desc: 'Approximate number of users' } do |counts|
|
2020-03-09 13:42:32 +05:30
|
|
|
approximate_count_with_delimiters(counts, ::User)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :projects,
|
|
|
|
documentation: { type: 'integer', example: 4, desc: 'Approximate number of projects' } do |counts|
|
2020-03-09 13:42:32 +05:30
|
|
|
approximate_count_with_delimiters(counts, ::Project)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :groups,
|
|
|
|
documentation: { type: 'integer', example: 1, desc: 'Approximate number of projects' } do |counts|
|
2020-03-09 13:42:32 +05:30
|
|
|
approximate_count_with_delimiters(counts, ::Group)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :active_users,
|
|
|
|
documentation: { type: 'integer', example: 21, desc: 'Number of active users' } do |_|
|
2020-03-09 13:42:32 +05:30
|
|
|
number_with_delimiter(::User.active.count)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|