debian-mirror-gitlab/lib/api/user_counts.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
960 B
Ruby
Raw Normal View History

2019-09-30 21:07:59 +05:30
# frozen_string_literal: true
module API
2021-01-03 14:25:43 +05:30
class UserCounts < ::API::Base
2021-01-29 00:20:46 +05:30
feature_category :navigation
2019-09-30 21:07:59 +05:30
resource :user_counts do
desc 'Return the user specific counts' do
2021-10-27 15:23:28 +05:30
detail 'Assigned open issues, assigned MRs and pending todos count'
2019-09-30 21:07:59 +05:30
end
get do
unauthorized! unless current_user
2022-05-07 20:08:51 +05:30
counts = {
2021-03-08 18:12:59 +05:30
merge_requests: current_user.assigned_open_merge_requests_count, # @deprecated
2021-10-27 15:23:28 +05:30
assigned_issues: current_user.assigned_open_issues_count,
2021-03-08 18:12:59 +05:30
assigned_merge_requests: current_user.assigned_open_merge_requests_count,
2021-10-27 15:23:28 +05:30
review_requested_merge_requests: current_user.review_requested_open_merge_requests_count,
todos: current_user.todos_pending_count
2019-09-30 21:07:59 +05:30
}
2022-05-07 20:08:51 +05:30
2022-07-16 23:28:13 +05:30
if current_user&.mr_attention_requests_enabled?
2022-05-07 20:08:51 +05:30
counts[:attention_requests] = current_user.attention_requested_open_merge_requests_count
end
counts
2019-09-30 21:07:59 +05:30
end
end
end
end