diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-05-23 14:29:21 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-05-23 14:29:21 +0300 |
commit | dab3ae39a2093fa924daf9c1902a2784002cca63 (patch) | |
tree | 9c183546ec1862740f589ecd47e29edf335db8f6 /app/serializers/pipeline_serializer.rb | |
parent | 8cca6c83a99100fcf3a0a3a56f10eebe3c9b7716 (diff) |
Do not paginate pipelines active relation twice
Diffstat (limited to 'app/serializers/pipeline_serializer.rb')
-rw-r--r-- | app/serializers/pipeline_serializer.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb index 7181f8a6b04..68325cbffa8 100644 --- a/app/serializers/pipeline_serializer.rb +++ b/app/serializers/pipeline_serializer.rb @@ -1,14 +1,12 @@ class PipelineSerializer < BaseSerializer include WithPagination - - InvalidResourceError = Class.new(StandardError) - entity PipelineDetailsEntity def represent(resource, opts = {}) if resource.is_a?(ActiveRecord::Relation) resource = resource.preload([ + :stages, :retryable_builds, :cancelable_statuses, :trigger_requests, @@ -19,11 +17,12 @@ class PipelineSerializer < BaseSerializer ]) end - if paginated? - super(@paginator.paginate(resource), opts) - else - super(resource, opts) + if opts.delete(:preload) + resource = @paginator.paginate(resource) if paginated? + resource = Gitlab::Ci::Pipeline::Preloader.preload!(resource) end + + super(resource, opts) end def represent_status(resource) |