Include resources to speed up pipelines serializer

This commit is contained in:
Grzegorz Bizon 2017-01-05 14:23:49 +01:00
parent ae5dc479e7
commit b5dfd03efc
3 changed files with 2 additions and 2 deletions

View file

@ -12,7 +12,6 @@ class Projects::PipelinesController < Projects::ApplicationController
.execute(scope: @scope)
.page(params[:page])
.per(30)
.includes(project: :namespace)
@running_or_pending_count = PipelinesFinder
.new(project).execute(scope: 'running').count

View file

@ -20,7 +20,6 @@ class PipelinesFinder
end
scoped_pipelines.order(id: :desc)
.includes(project: [:namespace])
end
private

View file

@ -5,6 +5,8 @@ class PipelineSerializer < BaseSerializer
Struct.new('Pagination', :request, :response)
def represent(resource, opts = {})
resource = resource.includes(project: :namespace)
if paginated?
raise InvalidResourceError unless resource.respond_to?(:page)