diff options
author | Sean McGivern <sean@gitlab.com> | 2019-01-11 11:28:52 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-01-11 11:28:52 +0000 |
commit | 7a10ef6e751e643b482a171a305c4ce485b1b039 (patch) | |
tree | a45a0a8d84e0efa1a3278918c287ae836cefb296 /app/finders | |
parent | b98f6e53f6fa97ef1166fb2da95909c79894fd28 (diff) | |
parent | 2490cfeeb2f8426b1a8f4e24bd0297e41a870ca2 (diff) | |
download | gitlab-ce-7a10ef6e751e643b482a171a305c4ce485b1b039.tar.gz |
Merge branch '53431-fix-upcoming-milestone-filter-for-groups' into 'master'
Add group milestones in upcoming filter
Closes #53431
See merge request gitlab-org/gitlab-ce!23098
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/issuable_finder.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index b73a3fa6e01..1a69ec85d18 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -149,6 +149,18 @@ class IssuableFinder end end + def related_groups + if project? && project && project.group && Ability.allowed?(current_user, :read_group, project.group) + project.group.self_and_ancestors + elsif group + [group] + elsif current_user + Gitlab::ObjectHierarchy.new(current_user.authorized_groups, current_user.groups).all_objects + else + [] + end + end + def project? params[:project_id].present? end @@ -163,8 +175,10 @@ class IssuableFinder end # rubocop: disable CodeReuse/ActiveRecord - def projects(items = nil) - return @projects = project if project? + def projects + return @projects if defined?(@projects) + + return @projects = [project] if project? projects = if current_user && params[:authorized_only].presence && !current_user_related? @@ -459,7 +473,7 @@ class IssuableFinder elsif filter_by_any_milestone? items = items.any_milestone elsif filter_by_upcoming_milestone? - upcoming_ids = Milestone.upcoming_ids_by_projects(projects(items)) + upcoming_ids = Milestone.upcoming_ids(projects, related_groups) items = items.left_joins_milestones.where(milestone_id: upcoming_ids) elsif filter_by_started_milestone? items = items.left_joins_milestones.where('milestones.start_date <= NOW()') |