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
ed11580c
Commit
ed11580c
authored
Nov 30, 2021
by
Vladimir Shushlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize finding environment for BlobController
Remove previously introduced feature flag Changelog: performance
parent
d178b976
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
38 deletions
+6
-38
app/finders/environments/environments_by_deployments_finder.rb
...inders/environments/environments_by_deployments_finder.rb
+5
-17
config/feature_flags/development/environments_by_deployments_finder_exists_optimization.yml
...nvironments_by_deployments_finder_exists_optimization.yml
+0
-8
spec/finders/environments/environments_by_deployments_finder_spec.rb
...s/environments/environments_by_deployments_finder_spec.rb
+1
-13
No files found.
app/finders/environments/environments_by_deployments_finder.rb
View file @
ed11580c
...
...
@@ -12,30 +12,18 @@ module Environments
# rubocop: disable CodeReuse/ActiveRecord
def
execute
deployments
=
project
.
deployments
deployments
=
if
ref
deployments_query
=
params
[
:with_tags
]
?
'ref = :ref OR tag IS TRUE'
:
'ref = :ref'
deployments
.
where
(
deployments_query
,
ref:
ref
.
to_s
)
Deployment
.
where
(
deployments_query
,
ref:
ref
.
to_s
)
elsif
commit
deployments
.
where
(
sha:
commit
.
sha
)
Deployment
.
where
(
sha:
commit
.
sha
)
else
deployments
.
none
Deployment
.
none
end
environments
=
if
Feature
.
enabled?
(
:environments_by_deployments_finder_exists_optimization
,
project
,
default_enabled: :yaml
)
# TODO: replace unscope with deployments = Deployment on top of the method https://gitlab.com/gitlab-org/gitlab/-/issues/343544
project
.
environments
.
available
.
where
(
'EXISTS (?)'
,
deployments
.
unscope
(
where: :project_id
).
where
(
'environment_id = environments.id'
))
else
environment_ids
=
deployments
.
group
(
:environment_id
)
.
select
(
:environment_id
)
project
.
environments
.
available
.
where
(
id:
environment_ids
)
end
environments
=
project
.
environments
.
available
.
where
(
'EXISTS (?)'
,
deployments
.
where
(
'environment_id = environments.id'
))
if
params
[
:find_latest
]
find_one
(
environments
.
order_by_last_deployed_at_desc
)
...
...
config/feature_flags/development/environments_by_deployments_finder_exists_optimization.yml
deleted
100644 → 0
View file @
d178b976
---
name
:
environments_by_deployments_finder_exists_optimization
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/72781/
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/343544
milestone
:
'
14.5'
type
:
development
group
:
group::release
default_enabled
:
false
spec/finders/environments/environments_by_deployments_finder_spec.rb
View file @
ed11580c
...
...
@@ -11,7 +11,7 @@ RSpec.describe Environments::EnvironmentsByDeploymentsFinder do
project
.
add_maintainer
(
user
)
end
shared_examples
'
execute'
do
describe
'#
execute'
do
context
'tagged deployment'
do
let
(
:environment_two
)
{
create
(
:environment
,
project:
project
)
}
# Environments need to include commits, so rewind two commits to fit
...
...
@@ -124,16 +124,4 @@ RSpec.describe Environments::EnvironmentsByDeploymentsFinder do
end
end
end
describe
"#execute"
do
include_examples
'execute'
context
'when environments_by_deployments_finder_exists_optimization is disabled'
do
before
do
stub_feature_flags
(
environments_by_deployments_finder_exists_optimization:
false
)
end
include_examples
'execute'
end
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