diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-06-21 08:24:03 +0200 |
---|---|---|
committer | Jarka Kadlecová <jarka@gitlab.com> | 2018-07-03 09:34:44 +0200 |
commit | 7458ca8ebb093af93c01cb61dabca15fd0c995cb (patch) | |
tree | dd8adc950f0ac762c4236a5f81519b89edf4aec7 /app/finders | |
parent | 57a44f2da3d2a0b59209b6c2d653d04efd0d3d41 (diff) | |
download | gitlab-ce-7458ca8ebb093af93c01cb61dabca15fd0c995cb.tar.gz |
[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')
-rw-r--r-- | app/finders/todos_finder.rb | 21 |
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 |