Class: Types::Namespaces::SidebarType

Inherits:
BaseObject
  • Object
show all
Defined in:
app/graphql/types/namespaces/sidebar_type.rb

Overview

rubocop:disable Graphql/AuthorizeTypes – parent is already authorized

Instance Method Summary collapse

Methods inherited from BaseObject

accepts, assignable?, authorization, authorization_scopes, authorize, authorized?, #current_user, #id

Methods included from Gitlab::Graphql::Present

#present, #unpresented

Instance Method Details

#group_open_issues_countObject



38
39
40
41
42
43
44
# File 'app/graphql/types/namespaces/sidebar_type.rb', line 38

def group_open_issues_count
  ::Groups::OpenIssuesCountService.new(namespace, context[:current_user], fast_timeout: true).count
rescue ActiveRecord::QueryCanceled => e # rubocop:disable Database/RescueQueryCanceled -- used with fast_read_statement_timeout to prevent this count from slowing down the rest of the request
  Gitlab::ErrorTracking.log_exception(e, group_id: namespace.id, query: 'group_sidebar_issues_count')

  nil
end

#open_issues_countObject



20
21
22
23
24
25
26
27
# File 'app/graphql/types/namespaces/sidebar_type.rb', line 20

def open_issues_count
  case namespace
  when ::Group
    group_open_issues_count
  when ::Namespaces::ProjectNamespace
    namespace.project.open_issues_count(context[:current_user])
  end
end

#open_merge_requests_countObject



29
30
31
32
33
34
35
36
# File 'app/graphql/types/namespaces/sidebar_type.rb', line 29

def open_merge_requests_count
  case namespace
  when Group
    ::Groups::MergeRequestsCountService.new(namespace, context[:current_user]).count
  when ::Namespaces::ProjectNamespace
    namespace.project.open_merge_requests_count
  end
end