Class: API::Entities::Project
- Inherits:
-
BasicProjectDetails
- Object
- Grape::Entity
- ProjectIdentity
- BasicProjectDetails
- API::Entities::Project
- Includes:
- Helpers::RelatedResourcesHelpers
- Defined in:
- lib/api/entities/project.rb
Direct Known Subclasses
Class Method Summary collapse
-
.forks_counting_projects(projects_relation) ⇒ Object
rubocop: enable CodeReuse/ActiveRecord.
-
.preload_relation(projects_relation, options = {}) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
Methods included from Helpers::RelatedResourcesHelpers
#expose_path, #expose_url, #issues_available?, #mrs_available?
Class Method Details
.forks_counting_projects(projects_relation) ⇒ Object
rubocop: enable CodeReuse/ActiveRecord
136 137 138 |
# File 'lib/api/entities/project.rb', line 136 def self.forks_counting_projects(projects_relation) projects_relation + projects_relation.map(&:forked_from_project).compact end |
.preload_relation(projects_relation, options = {}) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/api/entities/project.rb', line 119 def self.preload_relation(projects_relation, = {}) # Preloading tags, should be done with using only `:tags`, # as `:tags` are defined as: `has_many :tags, through: :taggings` # N+1 is solved then by using `subject.tags.map(&:name)` # MR describing the solution: https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/20555 super(projects_relation).preload(:group) .preload(:ci_cd_settings) .preload(:project_setting) .preload(:container_expiration_policy) .preload(:auto_devops) .preload(project_group_links: { group: :route }, fork_network: :root_project, fork_network_member: :forked_from_project, forked_from_project: [:route, :forks, :tags, namespace: :route]) end |