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
4ae25fdb
Commit
4ae25fdb
authored
Jun 01, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve performance and simplify queries on IssuesLink::ListService
parent
356635fa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
app/services/issue_links/list_service.rb
app/services/issue_links/list_service.rb
+12
-10
spec/services/issue_links/list_service_spec.rb
spec/services/issue_links/list_service_spec.rb
+1
-1
No files found.
app/services/issue_links/list_service.rb
View file @
4ae25fdb
...
@@ -24,16 +24,18 @@ module IssueLinks
...
@@ -24,16 +24,18 @@ module IssueLinks
private
private
def
issues
def
issues
referenced_issues
=
@issue
.
referenced_issues
.
select
(
'issues.*'
,
'issue_links.id AS issue_links_id'
)
authorized_issues
=
Issue
referred_by_issues
=
@issue
.
referred_by_issues
.
select
(
'issues.*'
,
'issue_links.id AS issue_links_id'
)
.
not_restricted_by_confidentiality
(
@current_user
)
authorized_issues
=
IssuesFinder
.
new
(
@current_user
).
execute
.
where
(
project_id:
@current_user
.
authorized_projects
.
select
(
:id
))
.
reorder
(
nil
)
union
=
Gitlab
::
SQL
::
Union
.
new
([
referenced_issues
,
referred_by_issues
])
Issue
.
from
(
"(SELECT issues.*, issue_links.id AS issue_links_id
Issue
.
from
(
"(
#{
union
.
to_sql
}
)
#{
Issue
.
table_name
}
"
)
FROM issue_links, issues
WHERE (issue_links.source_id = issues.id AND issue_links.target_id =
#{
@issue
.
id
}
)
OR (issue_links.target_id = issues.id AND issue_links.source_id =
#{
@issue
.
id
}
))
#{
Issue
.
table_name
}
"
)
.
where
(
id:
authorized_issues
.
select
(
:id
))
.
where
(
id:
authorized_issues
.
select
(
:id
))
.
preload
(
project: :namespace
)
.
preload
(
project: :namespace
)
.
reorder
(
'issue_links_id'
)
.
reorder
(
:issue_links_id
)
end
end
def
destroy_relation_path
(
issue
)
def
destroy_relation_path
(
issue
)
...
...
spec/services/issue_links/list_service_spec.rb
View file @
4ae25fdb
...
@@ -38,7 +38,7 @@ describe IssueLinks::ListService, service: true do
...
@@ -38,7 +38,7 @@ describe IssueLinks::ListService, service: true do
it
'verifies number of queries'
do
it
'verifies number of queries'
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expect
(
recorded
.
count
).
to
be_within
(
1
).
of
(
3
7
)
expect
(
recorded
.
count
).
to
be_within
(
1
).
of
(
3
5
)
end
end
it
'returns related issues JSON'
do
it
'returns related issues JSON'
do
...
...
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