Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
726f142d
Commit
726f142d
authored
Apr 09, 2019
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract preloaded_relations into method
parent
7b0f9f82
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
+23
-17
app/serializers/pipeline_serializer.rb
app/serializers/pipeline_serializer.rb
+23
-17
No files found.
app/serializers/pipeline_serializer.rb
View file @
726f142d
...
...
@@ -7,23 +7,7 @@ class PipelineSerializer < BaseSerializer
# rubocop: disable CodeReuse/ActiveRecord
def
represent
(
resource
,
opts
=
{})
if
resource
.
is_a?
(
ActiveRecord
::
Relation
)
resource
=
resource
.
preload
([
:stages
,
:retryable_builds
,
:cancelable_statuses
,
:trigger_requests
,
:manual_actions
,
:scheduled_actions
,
:artifacts
,
:merge_request
,
{
pending_builds: :project
,
project:
[
:route
,
{
namespace: :route
}],
artifacts:
{
project:
[
:route
,
{
namespace: :route
}]
}
}
])
resource
=
resource
.
preload
(
preloaded_relations
)
end
if
paginated?
...
...
@@ -51,4 +35,26 @@ class PipelineSerializer < BaseSerializer
data
=
represent
(
resource
,
{
only:
[{
details:
[
:stages
]
}],
preload:
true
})
data
.
dig
(
:details
,
:stages
)
||
[]
end
private
def
preloaded_relations
[
:stages
,
:retryable_builds
,
:cancelable_statuses
,
:trigger_requests
,
:manual_actions
,
:scheduled_actions
,
:artifacts
,
:merge_request
,
{
pending_builds: :project
,
project:
[
:route
,
{
namespace: :route
}],
artifacts:
{
project:
[
:route
,
{
namespace: :route
}]
}
}
]
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment