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
e442812f
Commit
e442812f
authored
Apr 10, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Issue multiple assignee] Use sub-query instead of join
parent
1b9c2010
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
13 deletions
+8
-13
app/finders/issues_finder.rb
app/finders/issues_finder.rb
+5
-8
app/models/issue.rb
app/models/issue.rb
+3
-5
No files found.
app/finders/issues_finder.rb
View file @
e442812f
...
@@ -39,18 +39,15 @@ class IssuesFinder < IssuableFinder
...
@@ -39,18 +39,15 @@ class IssuesFinder < IssuableFinder
end
end
def
self
.
not_restricted_by_confidentiality
(
user
)
def
self
.
not_restricted_by_confidentiality
(
user
)
issues
=
Issue
.
with_assignees
return
Issue
.
where
(
'issues.confidential IS NOT TRUE'
)
if
user
.
blank?
return
issues
.
where
(
'issues.confidential IS NULL OR issues.confidential IS FALSE'
)
if
user
.
blank
?
return
Issue
.
all
if
user
.
admin_or_auditor
?
return
issues
.
all
if
user
.
admin_or_auditor?
Issue
.
where
(
'
issues.confidential IS NOT TRUE
issues
.
where
(
'
issues.confidential IS NULL
OR issues.confidential IS FALSE
OR (issues.confidential = TRUE
OR (issues.confidential = TRUE
AND (issues.author_id = :user_id
AND (issues.author_id = :user_id
OR
issue_assignees.user_id = :user_id
OR
EXISTS (SELECT true FROM issue_assignees WHERE user_id = :user_id AND issue_id = issues.id)
OR issues.project_id IN(:project_ids)))'
,
OR issues.project_id IN(:project_ids)))'
,
user_id:
user
.
id
,
user_id:
user
.
id
,
project_ids:
user
.
authorized_projects
(
Gitlab
::
Access
::
REPORTER
).
select
(
:id
))
project_ids:
user
.
authorized_projects
(
Gitlab
::
Access
::
REPORTER
).
select
(
:id
))
...
...
app/models/issue.rb
View file @
e442812f
...
@@ -34,13 +34,11 @@ class Issue < ActiveRecord::Base
...
@@ -34,13 +34,11 @@ class Issue < ActiveRecord::Base
validates
:project
,
presence:
true
validates
:project
,
presence:
true
scope
:cared
,
->
(
user
)
{
with_assignees
.
where
(
"issue_assignees.user_id IN(?)"
,
user
.
id
)
}
scope
:open_for
,
->
(
user
)
{
opened
.
assigned_to
(
user
)
}
scope
:open_for
,
->
(
user
)
{
opened
.
assigned_to
(
user
)
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
)
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
)
}
scope
:with_assignees
,
->
{
joins
(
"LEFT JOIN issue_assignees ON issue_id = issues.id"
)
}
scope
:assigned
,
->
{
where
(
'EXISTS (SELECT * FROM issue_assignees WHERE issue_id = issues.id)'
)
}
scope
:assigned
,
->
{
with_assignees
.
where
(
'issue_assignees.user_id IS NOT NULL'
)
}
scope
:unassigned
,
->
{
where
(
'NOT EXISTS (SELECT * FROM issue_assignees WHERE issue_id = issues.id)'
)
}
scope
:unassigned
,
->
{
with_assignees
.
where
(
'issue_assignees.user_id IS NULL'
)
}
scope
:assigned_to
,
->
(
u
)
{
where
(
'EXISTS (SELECT true FROM issue_assignees WHERE user_id = ? AND issue_id = issues.id)'
,
u
.
id
)}
scope
:assigned_to
,
->
(
u
)
{
with_assignees
.
where
(
'issue_assignees.user_id = ?'
,
u
.
id
)}
scope
:without_due_date
,
->
{
where
(
due_date:
nil
)
}
scope
:without_due_date
,
->
{
where
(
due_date:
nil
)
}
scope
:due_before
,
->
(
date
)
{
where
(
'issues.due_date < ?'
,
date
)
}
scope
:due_before
,
->
(
date
)
{
where
(
'issues.due_date < ?'
,
date
)
}
...
...
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