summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-06-03 12:33:41 +0000
committerDouwe Maan <douwe@gitlab.com>2016-06-03 12:33:41 +0000
commit704991252604fbc14eef72e2eb1c2ad4629a7616 (patch)
tree3d754a42746bb34cb35a4f7c3645d75e81508423 /app
parent1637e178b8bae13fb92456570e23243c7ddc7cba (diff)
parent86675194aa44236c3e9acc4aa7ede143f718685e (diff)
downloadgitlab-ce-704991252604fbc14eef72e2eb1c2ad4629a7616.tar.gz
Merge branch 'todos-filter-project-delete' into 'master'
Ensure we don't show TODOS for projects pending delete ## What does this MR do? Joins the todos on the projects table in order to run the default scope. Also includes a where clause because the default scope is being removed soon. ## Are there points in the code the reviewer needs to double check? An alternative approach, more like the Issues page, would be to filter down the list by passing user.authorized_projects into the where clause. Or we could just be more defensive in the view when iterating. ## Why was this MR needed? Todos page throws 500 error for users with todos in a project pending deletion. ## What are the relevant issue numbers? Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/17813 cc\ @stanhu See merge request !4300
Diffstat (limited to 'app')
-rw-r--r--app/finders/todos_finder.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb
index 4bd46a76087..1d88116d7d2 100644
--- a/app/finders/todos_finder.rb
+++ b/app/finders/todos_finder.rb
@@ -30,7 +30,7 @@ class TodosFinder
items = by_state(items)
items = by_type(items)
- items
+ items.reorder(id: :desc)
end
private
@@ -78,6 +78,16 @@ class TodosFinder
@project
end
+ def projects
+ return @projects if defined?(@projects)
+
+ if project?
+ @projects = project
+ else
+ @projects = ProjectsFinder.new.execute(current_user)
+ end
+ end
+
def type?
type.present? && ['Issue', 'MergeRequest'].include?(type)
end
@@ -105,6 +115,8 @@ class TodosFinder
def by_project(items)
if project?
items = items.where(project: project)
+ elsif projects
+ items = items.merge(projects).joins(:project)
end
items