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
d13c36f7
Commit
d13c36f7
authored
Aug 12, 2016
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up todos queries by limiting the projects set we join with
Closes #20828
parent
a632ed69
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
11 deletions
+13
-11
CHANGELOG
CHANGELOG
+1
-0
app/finders/projects_finder.rb
app/finders/projects_finder.rb
+2
-1
app/finders/todos_finder.rb
app/finders/todos_finder.rb
+10
-10
No files found.
CHANGELOG
View file @
d13c36f7
...
...
@@ -110,6 +110,7 @@ v 8.11.0 (unreleased)
- Each `File::exists?` replaced to `File::exist?` because of deprecate since ruby version 2.2.0
- Add auto-completition in pipeline (Katarzyna Kobierska Ula Budziszewska)
- Fix a memory leak caused by Banzai::Filter::SanitizationFilter
- Speed up todos queries by limiting the projects set we join with
v 8.10.5
- Add a data migration to fix some missing timestamps in the members table. !5670
...
...
app/finders/projects_finder.rb
View file @
d13c36f7
class
ProjectsFinder
<
UnionFinder
def
execute
(
current_user
=
nil
,
options
=
{})
def
execute
(
current_user
=
nil
,
options
=
{}
,
&
block
)
segments
=
all_projects
(
current_user
)
segments
.
map!
(
&
block
)
if
block
find_union
(
segments
,
Project
)
end
...
...
app/finders/todos_finder.rb
View file @
d13c36f7
...
...
@@ -27,9 +27,11 @@ class TodosFinder
items
=
by_action_id
(
items
)
items
=
by_action
(
items
)
items
=
by_author
(
items
)
items
=
by_project
(
items
)
items
=
by_state
(
items
)
items
=
by_type
(
items
)
# Filtering by project HAS TO be the last because we use
# the project IDs yielded by the todos query thus far
items
=
by_project
(
items
)
items
.
reorder
(
id: :desc
)
end
...
...
@@ -91,13 +93,10 @@ class TodosFinder
@project
end
def
projects
return
@projects
if
defined?
(
@projects
)
if
project?
@projects
=
project
else
@projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
def
projects
(
items
)
item_project_ids
=
items
.
reorder
(
nil
).
select
(
:project_id
)
ProjectsFinder
.
new
.
execute
(
current_user
)
do
|
relation
|
relation
.
where
(
id:
item_project_ids
)
end
end
...
...
@@ -136,8 +135,9 @@ class TodosFinder
def
by_project
(
items
)
if
project?
items
=
items
.
where
(
project:
project
)
elsif
projects
items
=
items
.
merge
(
projects
).
joins
(
:project
)
else
item_projects
=
projects
(
items
)
items
=
items
.
merge
(
item_projects
).
joins
(
:project
)
end
items
...
...
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