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
c48976f5
Commit
c48976f5
authored
Jun 21, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename with_service to with_integration
This method eagerly loads an integration association.
parent
7c1f5b41
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
5 deletions
+8
-5
app/models/project.rb
app/models/project.rb
+1
-1
app/workers/clusters/applications/deactivate_service_worker.rb
...orkers/clusters/applications/deactivate_service_worker.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+6
-3
No files found.
app/models/project.rb
View file @
c48976f5
...
...
@@ -550,7 +550,7 @@ class Project < ApplicationRecord
scope
:with_namespace
,
->
{
includes
(
:namespace
)
}
scope
:with_import_state
,
->
{
includes
(
:import_state
)
}
scope
:include_project_feature
,
->
{
includes
(
:project_feature
)
}
scope
:with_
service
,
->
(
service
)
{
joins
(
service
).
eager_load
(
service
)
}
scope
:with_
integration
,
->
(
integration
)
{
joins
(
integration
).
eager_load
(
integration
)
}
scope
:with_shared_runners
,
->
{
where
(
shared_runners_enabled:
true
)
}
scope
:with_container_registry
,
->
{
where
(
container_registry_enabled:
true
)
}
scope
:inside_path
,
->
(
path
)
do
...
...
app/workers/clusters/applications/deactivate_service_worker.rb
View file @
c48976f5
...
...
@@ -15,7 +15,7 @@ module Clusters
raise
cluster_missing_error
(
integration_name
)
unless
cluster
integration
=
::
Project
.
integration_association_name
(
integration_name
).
to_sym
cluster
.
all_projects
.
with_
service
(
integration
).
find_each
do
|
project
|
cluster
.
all_projects
.
with_
integration
(
integration
).
find_each
do
|
project
|
project
.
public_send
(
integration
).
update!
(
active:
false
)
# rubocop:disable GitlabSecurity/PublicSend
end
end
...
...
spec/models/project_spec.rb
View file @
c48976f5
...
...
@@ -1557,13 +1557,16 @@ RSpec.describe Project, factory_default: :keep do
end
end
describe
'.with_
service
'
do
describe
'.with_
integration
'
do
before
do
create_list
(
:prometheus_project
,
2
)
end
it
'avoid n + 1'
do
expect
{
described_class
.
with_service
(
:prometheus_integration
).
map
(
&
:prometheus_integration
)
}.
not_to
exceed_query_limit
(
1
)
let
(
:integration
)
{
:prometheus_integration
}
it
'avoids n + 1'
do
expect
{
described_class
.
with_service
(
integration
).
map
(
&
integration
)
}
.
not_to
exceed_query_limit
(
1
)
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