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
bd2ebeda
Commit
bd2ebeda
authored
Feb 04, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport: Optimize slow pipelines.js response
Add changelog
parent
7f880007
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
2 deletions
+37
-2
app/models/ci/build.rb
app/models/ci/build.rb
+12
-2
changelogs/unreleased/use-deployment-relation-to-fetch-environment-ce.yml
...eased/use-deployment-relation-to-fetch-environment-ce.yml
+5
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+20
-0
No files found.
app/models/ci/build.rb
View file @
bd2ebeda
...
@@ -48,12 +48,22 @@ module Ci
...
@@ -48,12 +48,22 @@ module Ci
delegate
:trigger_short_token
,
to: :trigger_request
,
allow_nil:
true
delegate
:trigger_short_token
,
to: :trigger_request
,
allow_nil:
true
##
##
# The "environment" field for builds is a String, and is the unexpanded name!
# Since Gitlab 11.5, deployments records started being created right after
# `ci_builds` creation. We can look up a relevant `environment` through
# `deployment` relation today. This is much more efficient than expanding
# environment name with variables.
# (See more https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22380)
#
#
# However, we have to still expand environment name if it's a stop action,
# because `deployment` persists information for start action only.
#
# We will follow up this by persisting expanded name in build metadata or
# persisting stop action in database.
def
persisted_environment
def
persisted_environment
return
unless
has_environment?
return
unless
has_environment?
strong_memoize
(
:persisted_environment
)
do
strong_memoize
(
:persisted_environment
)
do
deployment
&
.
environment
||
Environment
.
find_by
(
name:
expanded_environment_name
,
project:
project
)
Environment
.
find_by
(
name:
expanded_environment_name
,
project:
project
)
end
end
end
end
...
...
changelogs/unreleased/use-deployment-relation-to-fetch-environment-ce.yml
0 → 100644
View file @
bd2ebeda
---
title
:
Use deployment relation to get an environment name
merge_request
:
24890
author
:
type
:
performance
spec/models/ci/build_spec.rb
View file @
bd2ebeda
...
@@ -1844,6 +1844,26 @@ describe Ci::Build do
...
@@ -1844,6 +1844,26 @@ describe Ci::Build do
context
'when there is no environment'
do
context
'when there is no environment'
do
it
{
is_expected
.
to
be_nil
}
it
{
is_expected
.
to
be_nil
}
end
end
context
'when build has a start environment'
do
let
(
:build
)
{
create
(
:ci_build
,
:deploy_to_production
,
pipeline:
pipeline
)
}
it
'does not expand environment name'
do
expect
(
build
).
not_to
receive
(
:expanded_environment_name
)
subject
end
end
context
'when build has a stop environment'
do
let
(
:build
)
{
create
(
:ci_build
,
:stop_review_app
,
pipeline:
pipeline
)
}
it
'expands environment name'
do
expect
(
build
).
to
receive
(
:expanded_environment_name
)
subject
end
end
end
end
describe
'#play'
do
describe
'#play'
do
...
...
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