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
Boxiang Sun
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
end
def
projects
return
if
project?
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
else
ProjectsFinder
.
new
.
execute
(
current_user
)
...
...
@@ -102,14 +102,7 @@ class IssuableFinder
@milestones
=
if
milestones?
scope
=
if
project
project
.
milestones
elsif
projects
Milestone
.
where
(
project_id:
projects
)
else
Milestone
.
none
end
scope
=
Milestone
.
where
(
project_id:
projects
)
scope
.
where
(
title:
params
[
:milestone_title
])
else
...
...
@@ -117,6 +110,14 @@ class IssuableFinder
end
end
def
labels?
params
[
:label_name
].
present?
end
def
no_labels?
labels?
&&
params
[
:label_name
]
==
Label
::
None
.
title
end
def
assignee?
params
[
:assignee_id
].
present?
end
...
...
@@ -189,9 +190,7 @@ class IssuableFinder
def
by_project
(
items
)
items
=
if
project
items
.
of_projects
(
project
)
elsif
projects
if
projects
items
.
of_projects
(
projects
).
references
(
:project
)
else
items
.
none
...
...
@@ -210,18 +209,6 @@ class IssuableFinder
items
.
sort
(
params
[
:sort
])
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
)
if
assignee?
items
=
items
.
where
(
assignee_id:
assignee
.
try
(
:id
))
...
...
@@ -238,9 +225,25 @@ class IssuableFinder
items
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
)
if
params
[
:label_name
].
present
?
if
params
[
:label_name
]
==
Label
::
None
.
title
if
labels
?
if
no_labels?
items
=
items
.
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
})
...
...
@@ -249,8 +252,8 @@ class IssuableFinder
items
=
items
.
joins
(
:labels
).
where
(
labels:
{
title:
label_names
})
if
project
items
=
items
.
where
(
'labels.project_id = :id'
,
id:
project
.
id
)
if
project
s
items
=
items
.
where
(
labels:
{
project_id:
projects
}
)
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