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
2ebcd8f4
Commit
2ebcd8f4
authored
Jan 12, 2021
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove is_blocked_by for issues
- remove IS_BLOCKED_BY from db queries - remove IS_BLOCKED_BY from specs
parent
d0db106b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
88 deletions
+32
-88
ee/app/models/ee/issue_link.rb
ee/app/models/ee/issue_link.rb
+17
-52
ee/spec/controllers/boards/issues_controller_spec.rb
ee/spec/controllers/boards/issues_controller_spec.rb
+2
-2
ee/spec/graphql/types/issue_type_spec.rb
ee/spec/graphql/types/issue_type_spec.rb
+1
-1
ee/spec/lib/ee/gitlab/issuable_metadata_spec.rb
ee/spec/lib/ee/gitlab/issuable_metadata_spec.rb
+1
-1
ee/spec/models/issue_link_spec.rb
ee/spec/models/issue_link_spec.rb
+6
-27
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+3
-3
ee/spec/requests/api/graphql/project/issues_spec.rb
ee/spec/requests/api/graphql/project/issues_spec.rb
+1
-1
ee/spec/requests/projects/issues_controller_spec.rb
ee/spec/requests/projects/issues_controller_spec.rb
+1
-1
No files found.
ee/app/models/ee/issue_link.rb
View file @
2ebcd8f4
...
...
@@ -22,67 +22,35 @@ module EE
end
def
blocked_issue_ids
(
issue_ids
)
blocked_
and_blocking_issues_union
(
issue_ids
).
pluck
(
:blocked_issue
_id
)
blocked_
or_blocking_issues
(
issue_ids
).
pluck
(
:target
_id
)
end
def
blocking_issue_ids_for
(
issue
)
blocked_
and_blocking_issues_union
(
issue
.
id
).
pluck
(
:blocking_issu
e_id
)
blocked_
or_blocking_issues
(
issue
.
id
).
pluck
(
:sourc
e_id
)
end
def
blocked_and_blocking_issues_union
(
issue_ids
)
from_union
([
blocked_or_blocking_issues
(
issue_ids
,
::
IssueLink
::
TYPE_BLOCKS
),
blocked_or_blocking_issues
(
issue_ids
,
::
IssueLink
::
TYPE_IS_BLOCKED_BY
)
])
end
def
blocked_or_blocking_issues
(
issue_ids
,
link_type
)
if
link_type
==
::
IssueLink
::
TYPE_BLOCKS
blocked_key
=
:target_id
blocking_key
=
:source_id
else
blocked_key
=
:source_id
blocking_key
=
:target_id
end
select
(
"
#{
blocked_key
}
as blocked_issue_id,
#{
blocking_key
}
as blocking_issue_id"
)
.
where
(
link_type:
link_type
).
where
(
blocked_key
=>
issue_ids
)
.
joins
(
"INNER JOIN issues ON issues.id = issue_links.
#{
blocking_key
}
"
)
.
where
(
'issues.state_id'
=>
::
Issuable
::
STATE_ID_MAP
[
:opened
])
def
blocked_or_blocking_issues
(
issue_ids
)
where
(
link_type:
::
IssueLink
::
TYPE_BLOCKS
).
where
(
target_id:
issue_ids
)
.
joins
(
:source
)
.
where
(
issues:
{
state_id:
::
Issue
.
available_states
[
:opened
]
})
end
def
blocking_issues_for_collection
(
issues_ids
)
open_state_id
=
::
Issuable
::
STATE_ID_MAP
[
:opened
]
from_union
([
select
(
"COUNT(CASE WHEN issues.state_id =
#{
open_state_id
}
then 1 else null end), issue_links.source_id AS blocking_issue_id"
)
.
joins
(
:target
)
.
where
(
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
.
where
(
source_id:
issues_ids
)
.
group
(
:blocking_issue_id
),
select
(
"COUNT(CASE WHEN issues.state_id =
#{
open_state_id
}
then 1 else null end), issue_links.target_id AS blocking_issue_id"
)
.
joins
(
:source
)
.
where
(
link_type:
::
IssueLink
::
TYPE_IS_BLOCKED_BY
)
.
where
(
target_id:
issues_ids
)
.
where
(
link_type:
::
IssueLink
::
TYPE_BLOCKS
,
source_id:
issues_ids
)
.
group
(
:blocking_issue_id
)
],
remove_duplicates:
false
).
select
(
'blocking_issue_id, SUM(count) AS count'
).
group
(
'blocking_issue_id'
)
end
def
blocked_issues_for_collection
(
issues_ids
)
from_union
([
select
(
'COUNT(*), issue_links.source_id AS blocked_issue_id'
)
.
joins
(
:target
)
.
where
(
issues:
{
state_id:
::
Issue
.
available_states
[
:opened
]
})
.
where
(
link_type:
::
IssueLink
::
TYPE_IS_BLOCKED_BY
)
.
where
(
source_id:
issues_ids
)
.
group
(
:blocked_issue_id
),
select
(
'COUNT(*), issue_links.target_id AS blocked_issue_id'
)
.
joins
(
:source
)
.
where
(
issues:
{
state_id:
::
Issue
.
available_states
[
:opened
]
})
.
where
(
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
.
where
(
target_id:
issues_ids
)
.
group
(
:blocked_issue_id
)
],
remove_duplicates:
false
).
select
(
'blocked_issue_id, SUM(count) AS count'
).
group
(
'blocked_issue_id'
)
end
def
blocking_issues_count_for
(
issue
)
...
...
@@ -93,10 +61,7 @@ module EE
private
def
blocking_issue
case
link_type
when
::
IssueLink
::
TYPE_BLOCKS
then
source
when
::
IssueLink
::
TYPE_IS_BLOCKED_BY
then
target
end
source
if
link_type
==
::
IssueLink
::
TYPE_BLOCKS
end
def
refresh_blocking_issue_cache
...
...
ee/spec/controllers/boards/issues_controller_spec.rb
View file @
2ebcd8f4
...
...
@@ -57,9 +57,9 @@ RSpec.describe Boards::IssuesController do
issue4
=
create
(
:labeled_issue
,
project:
project_1
,
labels:
[
development
],
relative_position:
4
)
closed_issue
=
create
(
:issue
,
:closed
,
project:
project_1
)
create
(
:issue_link
,
source:
issue
1
,
target:
issue2
,
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
)
create
(
:issue_link
,
source:
issue
2
,
target:
issue1
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
issue2
,
target:
issue3
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
issue4
,
target:
closed_issue
,
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
)
create
(
:issue_link
,
source:
closed_issue
,
target:
issue4
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
list_issues
user:
user
,
board:
board
,
list:
list2
...
...
ee/spec/graphql/types/issue_type_spec.rb
View file @
2ebcd8f4
...
...
@@ -30,7 +30,7 @@ RSpec.describe GitlabSchema.types['Issue'] do
blocked_issue2
=
create
(
:issue
,
project:
project
)
blocking_issue2
=
create
(
:issue
,
project:
project
)
create
:issue_link
,
source:
block
ed_issue2
,
target:
blocking_issue2
,
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
create
:issue_link
,
source:
block
ing_issue2
,
target:
blocked_issue2
,
link_type:
IssueLink
::
TYPE_BLOCKS
project2
=
create
(
:project
,
:public
,
group:
group
)
create
(
:issue
,
project:
project2
)
...
...
ee/spec/lib/ee/gitlab/issuable_metadata_spec.rb
View file @
2ebcd8f4
...
...
@@ -21,7 +21,7 @@ RSpec.describe Gitlab::IssuableMetadata do
create
(
:issue_link
,
source:
blocking_issue_1
,
target:
blocked_issue_1
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
blocking_issue_2
,
target:
blocked_issue_2
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
blocking_issue_1
,
target:
closed_blocked_issue
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
block
ed_issue_3
,
target:
blocking_issue_1
,
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
)
create
(
:issue_link
,
source:
block
ing_issue_1
,
target:
blocked_issue_3
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
end
it
'aggregates stats on issues'
do
...
...
ee/spec/models/issue_link_spec.rb
View file @
2ebcd8f4
...
...
@@ -17,15 +17,6 @@ RSpec.describe IssueLink do
end
end
context
'with TYPE_IS_BLOCKED_BY'
do
it
'updates blocking issues count'
do
expect
(
source
).
not_to
receive
(
:update_blocking_issues_count!
)
expect
(
target
).
to
receive
(
:update_blocking_issues_count!
)
create
(
:issue_link
,
target:
target
,
source:
source
,
link_type:
::
IssueLink
::
TYPE_IS_BLOCKED_BY
)
end
end
context
'with TYPE_RELATES_TO'
do
it
'does not update blocking_issues_count'
do
expect
(
source
).
not_to
receive
(
:update_blocking_issues_count!
)
...
...
@@ -48,17 +39,6 @@ RSpec.describe IssueLink do
end
end
context
'with TYPE_IS_BLOCKED_BY'
do
it
'updates blocking issues count'
do
link
=
create
(
:issue_link
,
target:
target
,
source:
source
,
link_type:
::
IssueLink
::
TYPE_IS_BLOCKED_BY
)
expect
(
source
).
not_to
receive
(
:update_blocking_issues_count!
)
expect
(
target
).
to
receive
(
:update_blocking_issues_count!
)
link
.
destroy!
end
end
context
'with TYPE_RELATES_TO'
do
it
'does not update blocking_issues_count'
do
link
=
create
(
:issue_link
,
target:
target
,
source:
source
,
link_type:
::
IssueLink
::
TYPE_RELATES_TO
)
...
...
@@ -75,12 +55,11 @@ RSpec.describe IssueLink do
describe
'.blocked_issue_ids'
do
it
'returns only ids of issues which are blocked'
do
link1
=
create
(
:issue_link
,
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
link2
=
create
(
:issue_link
,
link_type:
::
IssueLink
::
TYPE_IS_BLOCKED_BY
)
link3
=
create
(
:issue_link
,
link_type:
::
IssueLink
::
TYPE_RELATES_TO
)
link4
=
create
(
:issue_link
,
source:
create
(
:issue
,
:closed
),
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
link2
=
create
(
:issue_link
,
link_type:
::
IssueLink
::
TYPE_RELATES_TO
)
link3
=
create
(
:issue_link
,
source:
create
(
:issue
,
:closed
),
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
expect
(
described_class
.
blocked_issue_ids
([
link1
.
target_id
,
link2
.
source_id
,
link3
.
source_id
,
link4
.
target_id
]))
.
to
match_array
([
link1
.
target_id
,
link2
.
source_id
])
expect
(
described_class
.
blocked_issue_ids
([
link1
.
target_id
,
link2
.
source_id
,
link3
.
target_id
]))
.
to
match_array
([
link1
.
target_id
])
end
end
...
...
@@ -90,7 +69,7 @@ RSpec.describe IssueLink do
blocking_issue
=
create
(
:issue
,
project:
issue
.
project
)
blocked_by_issue
=
create
(
:issue
,
project:
issue
.
project
)
create
(
:issue_link
,
source:
blocking_issue
,
target:
issue
,
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
issue
,
target:
blocked_by_issue
,
link_type:
::
IssueLink
::
TYPE_IS_BLOCKED_BY
)
create
(
:issue_link
,
source:
blocked_by_issue
,
target:
issue
,
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
blocking_ids
=
described_class
.
blocking_issue_ids_for
(
issue
)
...
...
@@ -116,7 +95,7 @@ RSpec.describe IssueLink do
before
:all
do
create
(
:issue_link
,
source:
blocking_issue_1
,
target:
blocked_issue_1
,
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
block
ed_issue_2
,
target:
blocking_issue_1
,
link_type:
::
IssueLink
::
TYPE_IS_BLOCKED_BY
)
create
(
:issue_link
,
source:
block
ing_issue_1
,
target:
blocked_issue_2
,
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
blocking_issue_2
,
target:
blocked_issue_3
,
link_type:
::
IssueLink
::
TYPE_BLOCKS
)
end
...
...
ee/spec/models/issue_spec.rb
View file @
2ebcd8f4
...
...
@@ -729,8 +729,8 @@ RSpec.describe Issue do
before_all
do
create
(
:issue_link
,
source:
blocking_issue
,
target:
issue
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
other_project_blocking_issue
,
target:
issue
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
issue
,
target:
blocked_by_issue
,
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
)
create
(
:issue_link
,
source:
issue
,
target:
confidential_blocked_by_issue
,
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
)
create
(
:issue_link
,
source:
blocked_by_issue
,
target:
issue
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
confidential_blocked_by_issue
,
target:
issue
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
issue
,
target:
related_issue
,
link_type:
IssueLink
::
TYPE_RELATES_TO
)
create
(
:issue_link
,
source:
closed_blocking_issue
,
target:
issue
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
end
...
...
@@ -813,7 +813,7 @@ RSpec.describe Issue do
blocked_issue_2
=
create
(
:issue
,
project:
project
)
blocked_issue_3
=
create
(
:issue
,
project:
project
)
create
(
:issue_link
,
source:
issue
,
target:
blocked_issue_1
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
blocked_issue_2
,
target:
issue
,
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
)
create
(
:issue_link
,
source:
issue
,
target:
blocked_issue_2
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
issue
,
target:
blocked_issue_3
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
# Set to 0 for proper testing, this is being set by IssueLink callbacks.
issue
.
update
(
blocking_issues_count:
0
)
...
...
ee/spec/requests/api/graphql/project/issues_spec.rb
View file @
2ebcd8f4
...
...
@@ -54,7 +54,7 @@ RSpec.describe 'getting an issue list for a project' do
let_it_be
(
:blocking_issue2
)
{
create
(
:issue
,
:confidential
,
project:
project
)
}
let_it_be
(
:blocking_issue3
)
{
create
(
:issue
,
project:
project
)
}
let_it_be
(
:issue_link1
)
{
create
(
:issue_link
,
source:
block
ed_issue1
,
target:
blocking_issue1
,
link_type:
'is_blocked_by
'
)
}
let_it_be
(
:issue_link1
)
{
create
(
:issue_link
,
source:
block
ing_issue1
,
target:
blocked_issue1
,
link_type:
'blocks
'
)
}
let_it_be
(
:issue_link2
)
{
create
(
:issue_link
,
source:
blocking_issue2
,
target:
blocked_issue2
,
link_type:
'blocks'
)
}
let_it_be
(
:issue_link3
)
{
create
(
:issue_link
,
source:
blocking_issue3
,
target:
blocked_issue2
,
link_type:
'blocks'
)
}
...
...
ee/spec/requests/projects/issues_controller_spec.rb
View file @
2ebcd8f4
...
...
@@ -31,7 +31,7 @@ RSpec.describe Projects::IssuesController do
other_project_issue
=
create
(
:issue
)
other_project_issue
.
project
.
add_developer
(
user
)
create
(
:issue_link
,
source:
issue
,
target:
other_project_issue
,
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
)
create
(
:issue_link
,
source:
other_project_issue
,
target:
issue
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
expect
{
get_show
}.
not_to
exceed_query_limit
(
control
)
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