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
397835f2
Commit
397835f2
authored
Apr 14, 2021
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch '21068-optimize-issueable-updates' into 'master'"
This reverts merge request !58114
parent
0e81fa09
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
62 deletions
+16
-62
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+0
-8
app/models/concerns/milestoneable.rb
app/models/concerns/milestoneable.rb
+1
-3
app/services/issuable/bulk_update_service.rb
app/services/issuable/bulk_update_service.rb
+3
-10
changelogs/unreleased/21068-optimize-issueable-updates.yml
changelogs/unreleased/21068-optimize-issueable-updates.yml
+0
-5
ee/app/services/ee/issuable/bulk_update_service.rb
ee/app/services/ee/issuable/bulk_update_service.rb
+2
-5
ee/spec/models/concerns/ee/milestoneable_spec.rb
ee/spec/models/concerns/ee/milestoneable_spec.rb
+5
-5
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+0
-17
spec/models/concerns/milestoneable_spec.rb
spec/models/concerns/milestoneable_spec.rb
+5
-9
No files found.
app/models/concerns/issuable.rb
View file @
397835f2
...
...
@@ -137,14 +137,6 @@ module Issuable
scope
:references_project
,
->
{
references
(
:project
)
}
scope
:non_archived
,
->
{
join_project
.
where
(
projects:
{
archived:
false
})
}
scope
:includes_for_bulk_update
,
->
do
associations
=
%i[author assignees epic group labels metrics project source_project target_project]
.
select
do
|
association
|
reflect_on_association
(
association
)
end
includes
(
*
associations
)
end
attr_mentionable
:title
,
pipeline: :single_line
attr_mentionable
:description
...
...
app/models/concerns/milestoneable.rb
View file @
397835f2
...
...
@@ -39,13 +39,11 @@ module Milestoneable
private
def
milestone_is_valid
errors
.
add
(
:milestone_id
,
'is invalid'
)
if
respond_to?
(
:milestone_id
)
&&
!
milestone_available?
errors
.
add
(
:milestone_id
,
'is invalid'
)
if
respond_to?
(
:milestone_id
)
&&
milestone_id
.
present?
&&
!
milestone_available?
end
end
def
milestone_available?
return
true
if
milestone_id
.
blank?
project_id
==
milestone
&
.
project_id
||
project
.
ancestors_upto
.
compact
.
include?
(
milestone
&
.
group
)
end
...
...
app/services/issuable/bulk_update_service.rb
View file @
397835f2
...
...
@@ -15,7 +15,7 @@ module Issuable
set_update_params
(
type
)
items
=
update_issuables
(
type
,
ids
)
response_success
(
payload:
{
count:
items
.
size
})
response_success
(
payload:
{
count:
items
.
count
})
rescue
ArgumentError
=>
e
response_error
(
e
.
message
,
422
)
end
...
...
@@ -59,17 +59,10 @@ module Issuable
def
find_issuables
(
parent
,
model_class
,
ids
)
if
parent
.
is_a?
(
Project
)
projects
=
parent
model_class
.
id_in
(
ids
).
of_projects
(
parent
)
elsif
parent
.
is_a?
(
Group
)
projects
=
parent
.
all_projects
else
return
model_class
.
id_in
(
ids
).
of_projects
(
parent
.
all_projects
)
end
model_class
.
id_in
(
ids
)
.
of_projects
(
projects
)
.
includes_for_bulk_update
end
def
response_success
(
message:
nil
,
payload:
nil
)
...
...
changelogs/unreleased/21068-optimize-issueable-updates.yml
deleted
100644 → 0
View file @
0e81fa09
---
title
:
Optimize issuable updates
merge_request
:
58114
author
:
type
:
performance
ee/app/services/ee/issuable/bulk_update_service.rb
View file @
397835f2
...
...
@@ -9,12 +9,9 @@ module EE
override
:find_issuables
def
find_issuables
(
parent
,
model_class
,
ids
)
return
super
unless
model_class
==
::
Epic
return
model_class
.
id_in
(
ids
).
in_selected_groups
(
parent
.
self_and_descendants
)
if
model_class
==
::
Epic
model_class
.
id_in
(
ids
)
.
in_selected_groups
(
parent
.
self_and_descendants
)
.
includes_for_bulk_update
super
end
override
:permitted_attrs
...
...
ee/spec/models/concerns/ee/milestoneable_spec.rb
View file @
397835f2
...
...
@@ -4,11 +4,11 @@ require 'spec_helper'
RSpec
.
describe
EE
::
Milestoneable
do
describe
'#milestone_available?'
do
context
'
for epics
'
do
let
(
:
epic
)
{
build
(
:epic
)
}
context
'
no Epic
'
do
let
(
:
issue
)
{
create
(
:issue
)
}
it
'returns
tru
e'
do
expect
(
epic
.
milestone_available?
).
to
be
(
true
)
it
'returns
fals
e'
do
expect
(
issue
.
milestone_available?
).
to
be_falsy
end
end
end
...
...
@@ -21,7 +21,7 @@ RSpec.describe EE::Milestoneable do
let
(
:epic
)
{
build
(
:epic
)
}
it
'returns false'
do
expect
(
epic
.
supports_milestone?
).
to
be
(
false
)
expect
(
epic
.
supports_milestone?
).
to
be
_falsy
end
end
end
...
...
spec/models/concerns/issuable_spec.rb
View file @
397835f2
...
...
@@ -65,23 +65,6 @@ RSpec.describe Issuable do
it
{
expect
(
issuable_class
).
to
respond_to
(
:opened
)
}
it
{
expect
(
issuable_class
).
to
respond_to
(
:closed
)
}
it
{
expect
(
issuable_class
).
to
respond_to
(
:assigned
)
}
describe
'.includes_for_bulk_update'
do
before
do
stub_const
(
'Example'
,
Class
.
new
(
ActiveRecord
::
Base
))
Example
.
class_eval
do
include
Issuable
# adds :labels and :metrics, among others
belongs_to
:author
has_many
:assignees
end
end
it
'includes available associations'
do
expect
(
Example
.
includes_for_bulk_update
.
includes_values
).
to
eq
([
:author
,
:assignees
,
:labels
,
:metrics
])
end
end
end
describe
'author_name'
do
...
...
spec/models/concerns/milestoneable_spec.rb
View file @
397835f2
...
...
@@ -50,13 +50,13 @@ RSpec.describe Milestoneable do
it
'returns true with a milestone from the issue project'
do
milestone
=
create
(
:milestone
,
project:
project
)
expect
(
build_milestoneable
(
milestone
.
id
).
milestone_available?
).
to
be
(
true
)
expect
(
build_milestoneable
(
milestone
.
id
).
milestone_available?
).
to
be
_truthy
end
it
'returns true with a milestone from the issue project group'
do
milestone
=
create
(
:milestone
,
group:
group
)
expect
(
build_milestoneable
(
milestone
.
id
).
milestone_available?
).
to
be
(
true
)
expect
(
build_milestoneable
(
milestone
.
id
).
milestone_available?
).
to
be
_truthy
end
it
'returns true with a milestone from the the parent of the issue project group'
do
...
...
@@ -64,23 +64,19 @@ RSpec.describe Milestoneable do
group
.
update!
(
parent:
parent
)
milestone
=
create
(
:milestone
,
group:
parent
)
expect
(
build_milestoneable
(
milestone
.
id
).
milestone_available?
).
to
be
(
true
)
end
it
'returns true with a blank milestone'
do
expect
(
build_milestoneable
(
''
).
milestone_available?
).
to
be
(
true
)
expect
(
build_milestoneable
(
milestone
.
id
).
milestone_available?
).
to
be_truthy
end
it
'returns false with a milestone from another project'
do
milestone
=
create
(
:milestone
)
expect
(
build_milestoneable
(
milestone
.
id
).
milestone_available?
).
to
be
(
false
)
expect
(
build_milestoneable
(
milestone
.
id
).
milestone_available?
).
to
be
_falsey
end
it
'returns false with a milestone from another group'
do
milestone
=
create
(
:milestone
,
group:
create
(
:group
))
expect
(
build_milestoneable
(
milestone
.
id
).
milestone_available?
).
to
be
(
false
)
expect
(
build_milestoneable
(
milestone
.
id
).
milestone_available?
).
to
be
_falsey
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