Commit 0e2f1829 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Use INNER JOIN + Ability.issues_readable_by_user on IssueLinks::ListService

parent 56016b7b
...@@ -24,18 +24,16 @@ module IssueLinks ...@@ -24,18 +24,16 @@ module IssueLinks
private private
def issues def issues
authorized_issues = IssuesFinder related_issues = Issue
.new(@current_user, feature_availability_check: false) .select(['issues.*', 'issue_links.id AS issue_links_id'])
.execute .joins("INNER JOIN issue_links ON
.reorder(nil) (issue_links.source_id = issues.id AND issue_links.target_id = #{@issue.id})
OR
Issue.from("(SELECT issues.*, issue_links.id AS issue_links_id (issue_links.target_id = issues.id AND issue_links.source_id = #{@issue.id})")
FROM issue_links, issues .preload(project: :namespace)
WHERE (issue_links.source_id = issues.id AND issue_links.target_id = #{@issue.id}) .reorder('issue_links_id')
OR (issue_links.target_id = issues.id AND issue_links.source_id = #{@issue.id})) #{Issue.table_name}")
.where(id: authorized_issues.select(:id)) Ability.issues_readable_by_user(related_issues, @current_user)
.preload(project: :namespace)
.reorder(:issue_links_id)
end end
def destroy_relation_path(issue) def destroy_relation_path(issue)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment