Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-03-01 19:16:39 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2018-03-02 16:53:38 +0300
commitf09fe848da02189a3dafe2d532fefb1379eacac4 (patch)
tree354308e1803370dc3e4cbe52078cd8b670cacbed /app/finders/todos_finder.rb
parentde454de9b10f0dd534884c8ffeabe3e534993349 (diff)
Don't use ProjectsFinder in TodosFinder
Using ProjectsFinder in TodosFinder to limit todos to the right projects leads to overly complicated and slow database queries. This commit removes the use of ProjectsFinder in favour of using Project.public_or_visible_to_current_user directly. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/43767
Diffstat (limited to 'app/finders/todos_finder.rb')
-rw-r--r--app/finders/todos_finder.rb15
1 files changed, 6 insertions, 9 deletions
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb
index edb17843002..47c8b9b60ed 100644
--- a/app/finders/todos_finder.rb
+++ b/app/finders/todos_finder.rb
@@ -110,10 +110,6 @@ class TodosFinder
ids
end
- def projects(items)
- ProjectsFinder.new(current_user: current_user, project_ids_relation: project_ids(items)).execute
- end
-
def type?
type.present? && %w(Issue MergeRequest).include?(type)
end
@@ -152,13 +148,14 @@ class TodosFinder
def by_project(items)
if project?
- items = items.where(project: project)
+ items.where(project: project)
else
- item_projects = projects(items)
- items = items.merge(item_projects).joins(:project)
- end
+ projects = Project
+ .public_or_visible_to_user(current_user)
+ .order_id_desc
- items
+ items.joins(:project).merge(projects)
+ end
end
def by_state(items)