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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
0108cdf4
Commit
0108cdf4
authored
Oct 16, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve performance of filtering issues by milestone
parent
9127ae5c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
30 deletions
+33
-30
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+33
-30
No files found.
app/finders/issuable_finder.rb
View file @
0108cdf4
...
@@ -74,11 +74,11 @@ class IssuableFinder
...
@@ -74,11 +74,11 @@ class IssuableFinder
end
end
def
projects
def
projects
return
if
project?
return
@projects
if
defined?
(
@projects
)
return
@projects
if
defined?
(
@projects
)
if
current_user
&&
params
[
:authorized_only
].
presence
&&
!
current_user_related?
if
project?
project
elsif
current_user
&&
params
[
:authorized_only
].
presence
&&
!
current_user_related?
current_user
.
authorized_projects
current_user
.
authorized_projects
else
else
ProjectsFinder
.
new
.
execute
(
current_user
)
ProjectsFinder
.
new
.
execute
(
current_user
)
...
@@ -102,14 +102,7 @@ class IssuableFinder
...
@@ -102,14 +102,7 @@ class IssuableFinder
@milestones
=
@milestones
=
if
milestones?
if
milestones?
scope
=
scope
=
Milestone
.
where
(
project_id:
projects
)
if
project
project
.
milestones
elsif
projects
Milestone
.
where
(
project_id:
projects
)
else
Milestone
.
none
end
scope
.
where
(
title:
params
[
:milestone_title
])
scope
.
where
(
title:
params
[
:milestone_title
])
else
else
...
@@ -117,6 +110,14 @@ class IssuableFinder
...
@@ -117,6 +110,14 @@ class IssuableFinder
end
end
end
end
def
labels?
params
[
:label_name
].
present?
end
def
no_labels?
labels?
&&
params
[
:label_name
]
==
Label
::
None
.
title
end
def
assignee?
def
assignee?
params
[
:assignee_id
].
present?
params
[
:assignee_id
].
present?
end
end
...
@@ -189,9 +190,7 @@ class IssuableFinder
...
@@ -189,9 +190,7 @@ class IssuableFinder
def
by_project
(
items
)
def
by_project
(
items
)
items
=
items
=
if
project
if
projects
items
.
of_projects
(
project
)
elsif
projects
items
.
of_projects
(
projects
).
references
(
:project
)
items
.
of_projects
(
projects
).
references
(
:project
)
else
else
items
.
none
items
.
none
...
@@ -210,18 +209,6 @@ class IssuableFinder
...
@@ -210,18 +209,6 @@ class IssuableFinder
items
.
sort
(
params
[
:sort
])
items
.
sort
(
params
[
:sort
])
end
end
def
by_milestone
(
items
)
if
milestones?
if
no_milestones?
items
=
items
.
where
(
milestone_id:
[
-
1
,
nil
])
else
items
=
items
.
where
(
milestone_id:
milestones
.
try
(
:pluck
,
:id
))
end
end
items
end
def
by_assignee
(
items
)
def
by_assignee
(
items
)
if
assignee?
if
assignee?
items
=
items
.
where
(
assignee_id:
assignee
.
try
(
:id
))
items
=
items
.
where
(
assignee_id:
assignee
.
try
(
:id
))
...
@@ -238,9 +225,25 @@ class IssuableFinder
...
@@ -238,9 +225,25 @@ class IssuableFinder
items
items
end
end
def
by_milestone
(
items
)
if
milestones?
if
no_milestones?
items
=
items
.
where
(
milestone_id:
[
-
1
,
nil
])
else
items
=
items
.
joins
(
:milestone
).
where
(
milestones:
{
title:
params
[
:milestone_title
]
})
if
projects
items
=
items
.
where
(
milestones:
{
project_id:
projects
})
end
end
end
items
end
def
by_label
(
items
)
def
by_label
(
items
)
if
params
[
:label_name
].
present
?
if
labels
?
if
params
[
:label_name
]
==
Label
::
None
.
title
if
no_labels?
items
=
items
.
items
=
items
.
joins
(
"LEFT OUTER JOIN label_links ON label_links.target_type = '
#{
klass
.
name
}
' AND label_links.target_id =
#{
klass
.
table_name
}
.id"
).
joins
(
"LEFT OUTER JOIN label_links ON label_links.target_type = '
#{
klass
.
name
}
' AND label_links.target_id =
#{
klass
.
table_name
}
.id"
).
where
(
label_links:
{
id:
nil
})
where
(
label_links:
{
id:
nil
})
...
@@ -249,8 +252,8 @@ class IssuableFinder
...
@@ -249,8 +252,8 @@ class IssuableFinder
items
=
items
.
joins
(
:labels
).
where
(
labels:
{
title:
label_names
})
items
=
items
.
joins
(
:labels
).
where
(
labels:
{
title:
label_names
})
if
project
if
project
s
items
=
items
.
where
(
'labels.project_id = :id'
,
id:
project
.
id
)
items
=
items
.
where
(
labels:
{
project_id:
projects
}
)
end
end
end
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