Class: API::Entities::BasicProjectDetails

Inherits:
ProjectIdentity show all
Includes:
ProjectsRelationBuilder
Defined in:
lib/api/entities/basic_project_details.rb

Direct Known Subclasses

Project

Class Method Summary collapse

Class Method Details

.preload_relation(projects_relation, options = {}) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


43
44
45
46
47
48
49
50
51
52
# File 'lib/api/entities/basic_project_details.rb', line 43

def self.preload_relation(projects_relation, options = {})
  # 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
  projects_relation.preload(:project_feature, :route)
                   .preload(:import_state, :tags)
                   .preload(:auto_devops)
                   .preload(namespace: [:route, :owner])
end