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:
authorJan Provaznik <jprovaznik@gitlab.com>2018-06-21 09:24:03 +0300
committerJarka Kadlecová <jarka@gitlab.com>2018-07-03 10:34:44 +0300
commit7458ca8ebb093af93c01cb61dabca15fd0c995cb (patch)
treedd8adc950f0ac762c4236a5f81519b89edf4aec7 /app/finders/todos_finder.rb
parent57a44f2da3d2a0b59209b6c2d653d04efd0d3d41 (diff)
[backend] Addressed review comments
* Group filtering now includes also issues/MRs from subgroups/subprojects * fixed due_date * Also DRYed todo controller specs
Diffstat (limited to 'app/finders/todos_finder.rb')
-rw-r--r--app/finders/todos_finder.rb21
1 files changed, 8 insertions, 13 deletions
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb
index 1dfcf19b78d..ea1420712a7 100644
--- a/app/finders/todos_finder.rb
+++ b/app/finders/todos_finder.rb
@@ -113,16 +113,6 @@ class TodosFinder
end
end
- def project_ids(items)
- ids = items.except(:order).select(:project_id)
- if Gitlab::Database.mysql?
- # To make UPDATE work on MySQL, wrap it in a SELECT with an alias
- ids = Todo.except(:order).select('*').from("(#{ids.to_sql}) AS t")
- end
-
- ids
- end
-
def type?
type.present? && %w(Issue MergeRequest Epic).include?(type)
end
@@ -169,7 +159,12 @@ class TodosFinder
def by_group(items)
if group?
- items = items.where(group: group)
+ groups = group.self_and_descendants
+ items = items.where(
+ 'project_id IN (?) OR group_id IN (?)',
+ Project.where(group: groups).select(:id),
+ groups.select(:id)
+ )
end
items
@@ -184,8 +179,8 @@ class TodosFinder
.joins('LEFT JOIN projects ON projects.id = todos.project_id')
.where(
'project_id IN (?) OR group_id IN (?)',
- projects.map(&:id),
- groups.map(&:id)
+ projects.select(:id),
+ groups.select(:id)
)
end