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
aa7a3d48
Commit
aa7a3d48
authored
May 14, 2021
by
Tetiana Chupryna
Committed by
Jan Provaznik
May 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix another repeating queries
parent
0289efc2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
4 deletions
+38
-4
app/services/labels/find_or_create_service.rb
app/services/labels/find_or_create_service.rb
+4
-2
changelogs/unreleased/194104-part-2.yml
changelogs/unreleased/194104-part-2.yml
+5
-0
ee/lib/api/epics.rb
ee/lib/api/epics.rb
+0
-2
spec/services/labels/find_or_create_service_spec.rb
spec/services/labels/find_or_create_service_spec.rb
+29
-0
No files found.
app/services/labels/find_or_create_service.rb
View file @
aa7a3d48
...
...
@@ -6,7 +6,7 @@ module Labels
@current_user
=
current_user
@parent
=
parent
@available_labels
=
params
.
delete
(
:available_labels
)
@existing_labels_by_title
=
params
.
delete
(
:existing_labels_by_title
)
||
{}
@existing_labels_by_title
=
params
.
delete
(
:existing_labels_by_title
)
@params
=
params
.
dup
.
with_indifferent_access
end
...
...
@@ -45,7 +45,9 @@ module Labels
# rubocop: disable CodeReuse/ActiveRecord
def
find_existing_label
(
title
)
existing_labels_by_title
[
title
]
||
available_labels
.
find_by
(
title:
title
)
return
existing_labels_by_title
[
title
]
if
existing_labels_by_title
available_labels
.
find_by
(
title:
title
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
changelogs/unreleased/194104-part-2.yml
0 → 100644
View file @
aa7a3d48
---
title
:
Fix repeating SQL queries when changing labels for a resource.
merge_request
:
60718
author
:
type
:
performance
ee/lib/api/epics.rb
View file @
aa7a3d48
...
...
@@ -115,8 +115,6 @@ module API
at_least_one_of
:title
,
:description
,
:start_date_fixed
,
:start_date_is_fixed
,
:due_date_fixed
,
:due_date_is_fixed
,
:labels
,
:add_labels
,
:remove_labels
,
:state_event
,
:confidential
end
put
':id/(-/)epics/:epic_iid'
do
Gitlab
::
QueryLimiting
.
disable!
(
'https://gitlab.com/gitlab-org/gitlab/issues/194104'
)
authorize_can_admin_epic!
# Setting updated_at is allowed only for admins and owners
...
...
spec/services/labels/find_or_create_service_spec.rb
View file @
aa7a3d48
...
...
@@ -25,6 +25,35 @@ RSpec.describe Labels::FindOrCreateService do
project
.
add_developer
(
user
)
end
context
'when existing_labels_by_title is provided'
do
let
(
:preloaded_label
)
{
build
(
:label
,
title:
'Security'
)
}
before
do
params
.
merge!
(
existing_labels_by_title:
{
'Security'
=>
preloaded_label
})
end
context
'when label exists'
do
it
'returns preloaded label'
do
expect
(
service
.
execute
).
to
eq
preloaded_label
end
end
context
'when label does not exists'
do
before
do
params
[
:title
]
=
'Audit'
end
it
'does not generates additional label search'
do
service
.
execute
expect
(
LabelsFinder
).
not_to
receive
(
:new
)
end
end
end
context
'when label does not exist at group level'
do
it
'creates a new label at project level'
do
expect
{
service
.
execute
}.
to
change
(
project
.
labels
,
:count
).
by
(
1
)
...
...
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