Class: API::Entities::BasicProjectDetails
- Inherits:
-
ProjectIdentity
- Object
- Grape::Entity
- ProjectIdentity
- API::Entities::BasicProjectDetails
- Includes:
- ProjectsRelationBuilder, Gitlab::Utils::StrongMemoize
- Defined in:
- lib/api/entities/basic_project_details.rb
Direct Known Subclasses
Class Method Summary collapse
-
.execute_batch_counting(projects_relation) ⇒ Object
rubocop: enable CodeReuse/ActiveRecord.
- .postload_relation(projects_relation, options = {}) ⇒ Object
-
.preload_relation(projects_relation, options = {}) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
Class Method Details
.execute_batch_counting(projects_relation) ⇒ Object
rubocop: enable CodeReuse/ActiveRecord
57 58 59 60 61 62 63 |
# File 'lib/api/entities/basic_project_details.rb', line 57 def self.execute_batch_counting(projects_relation) # Call the count methods on every project, so the BatchLoader would load them all at # once when the entities are rendered projects_relation.each(&:forks_count) super end |
.postload_relation(projects_relation, options = {}) ⇒ Object
65 |
# File 'lib/api/entities/basic_project_details.rb', line 65 def self.postload_relation(projects_relation, = {}) end |
.preload_relation(projects_relation, options = {}) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/api/entities/basic_project_details.rb', line 45 def self.preload_relation(projects_relation, = {}) # Preloading topics, should be done with using only `:topics`, # as `:topics` are defined as: `has_many :topics, through: :project_topics` # N+1 is solved then by using `subject.topics.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, :topics) .preload(:auto_devops) .preload(namespace: [:route, :owner]) end |