diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2019-01-17 14:31:42 +0000 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2019-01-17 14:31:42 +0000 |
commit | e520a946410ca0007a2a562f2c2a7c6f8c6f1dab (patch) | |
tree | b25f4a503cafe2cbdda834880f0cbb43b8297ba0 /app/models | |
parent | 8547b5460708ad7e5b159e442c6c4c5ee1c2d8ac (diff) | |
parent | 2f76ff19f8f520a584a1259bd0c779e988cd7360 (diff) | |
download | gitlab-ce-e520a946410ca0007a2a562f2c2a7c6f8c6f1dab.tar.gz |
Merge branch '47988-improve-milestone-queries-with-subq' into 'master'
Improve MilestonesFinder to accept project and group relations
Closes #47988
See merge request gitlab-org/gitlab-ce!24325
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/milestone.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 1ebcbcda0d8..b21edce3aad 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -45,7 +45,7 @@ class Milestone < ActiveRecord::Base groups = groups.compact if groups.is_a? Array groups = [] if groups.nil? - where(project: projects).or(where(group: groups)) + where(project_id: projects).or(where(group_id: groups)) end scope :order_by_name_asc, -> { order(Arel::Nodes::Ascending.new(arel_table[:title].lower)) } @@ -191,7 +191,7 @@ class Milestone < ActiveRecord::Base return STATE_COUNT_HASH unless projects || groups counts = Milestone - .for_projects_and_groups(projects&.map(&:id), groups&.map(&:id)) + .for_projects_and_groups(projects, groups) .reorder(nil) .group(:state) .count @@ -275,8 +275,7 @@ class Milestone < ActiveRecord::Base if project relation = Milestone.for_projects_and_groups([project_id], [project.group&.id]) elsif group - project_ids = group.projects.map(&:id) - relation = Milestone.for_projects_and_groups(project_ids, [group.id]) + relation = Milestone.for_projects_and_groups(group.projects.select(:id), [group.id]) end title_exists = relation.find_by_title(title) |