Class: Types::ProjectType
Instance Method Summary
collapse
Methods inherited from BaseObject
accepts, assignable?, authorization, authorize, authorized?, #current_user, #id
#present, #unpresented
Instance Method Details
#avatar_url ⇒ Object
668
669
670
|
# File 'app/graphql/types/project_type.rb', line 668
def avatar_url
object.avatar_url(only_path: false)
end
|
#ci_config_variables(ref:) ⇒ Object
702
703
704
705
706
707
708
709
710
|
# File 'app/graphql/types/project_type.rb', line 702
def ci_config_variables(ref:)
result = ::Ci::ListConfigVariablesService.new(object, context[:current_user]).execute(ref)
return if result.nil?
result.map do |var_key, var_config|
{ key: var_key, **var_config }
end
end
|
#container_repositories_count ⇒ Object
698
699
700
|
# File 'app/graphql/types/project_type.rb', line 698
def container_repositories_count
project.container_repositories.size
end
|
#forks_count ⇒ Object
680
681
682
|
# File 'app/graphql/types/project_type.rb', line 680
def forks_count
BatchLoader::GraphQL.wrap(object.forks_count)
end
|
#is_catalog_resource ⇒ Object
rubocop:disable Naming/PredicateName
684
685
686
687
688
689
690
691
692
|
# File 'app/graphql/types/project_type.rb', line 684
def is_catalog_resource lazy_catalog_resource = BatchLoader::GraphQL.for(object.id).batch do |project_ids, loader|
::Ci::Catalog::Resource.for_projects(project_ids).each do |catalog_resource|
loader.call(catalog_resource.project_id, catalog_resource)
end
end
Gitlab::Graphql::Lazy.with_value(lazy_catalog_resource, &:present?)
end
|
#job(id:) ⇒ Object
712
713
714
715
|
# File 'app/graphql/types/project_type.rb', line 712
def job(id:)
object.commit_statuses.find(id.model_id)
rescue ActiveRecord::RecordNotFound
end
|
#jobs_enabled ⇒ Object
672
673
674
|
# File 'app/graphql/types/project_type.rb', line 672
def jobs_enabled
object.feature_available?(:builds, context[:current_user])
end
|
#label(title:) ⇒ Object
642
643
644
645
646
647
648
649
|
# File 'app/graphql/types/project_type.rb', line 642
def label(title:)
BatchLoader::GraphQL.for(title).batch(key: project) do |titles, loader, args|
LabelsFinder
.new(current_user, project: args[:key], title: titles)
.execute
.each { |label| loader.call(label.title, label) }
end
end
|
#open_issues_count ⇒ Object
676
677
678
|
# File 'app/graphql/types/project_type.rb', line 676
def open_issues_count
BatchLoader::GraphQL.wrap(object.open_issues_count) if object.feature_available?(:issues, context[:current_user])
end
|
#sast_ci_configuration ⇒ Object
#service_desk_address ⇒ Object
728
729
730
731
732
|
# File 'app/graphql/types/project_type.rb', line 728
def service_desk_address
return unless Ability.allowed?(current_user, :admin_issue, project)
object.service_desk_address
end
|
#statistics_details_paths ⇒ Object
#timelog_categories ⇒ Object
638
639
640
|
# File 'app/graphql/types/project_type.rb', line 638
def timelog_categories
object.project_namespace.timelog_categories if Feature.enabled?(:timelog_categories)
end
|
#visible_forks(minimum_access_level: nil) ⇒ Object
738
739
740
741
742
743
744
745
746
|
# File 'app/graphql/types/project_type.rb', line 738
def visible_forks(minimum_access_level: nil)
if minimum_access_level.nil?
object.forks.public_or_visible_to_user(current_user)
else
return [] if current_user.nil?
object.forks.visible_to_user_and_access_level(current_user, minimum_access_level)
end
end
|