Commit 86590f1e authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'ag-add-created-scope-for-group-members' into 'master'

Use CreatedAtFilter in GroupMemberFinder

See merge request gitlab-org/gitlab!28011
parents e1c73a69 c2ac5bc3
# frozen_string_literal: true
class GroupMembersFinder < UnionFinder
include CreatedAtFilter
# Params can be any of the following:
# two_factor: string. 'enabled' or 'disabled' are returning different set of data, other values are not effective.
# sort: string
# search: string
# created_after: datetime
# created_before: datetime
def initialize(group, user = nil)
@group = group
......@@ -15,6 +19,7 @@ class GroupMembersFinder < UnionFinder
def execute(include_relations: [:inherited, :direct], params: {})
group_members = group.members
relations = []
@params = params
return group_members if include_relations == [:direct]
......@@ -39,15 +44,15 @@ class GroupMembersFinder < UnionFinder
return GroupMember.none if relations.empty?
members = find_union(relations, GroupMember)
filter_members(members, params)
filter_members(members)
end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :user, :group
attr_reader :user, :group, :params
def filter_members(members, params)
def filter_members(members)
members = members.search(params[:search]) if params[:search].present?
members = members.sort_by_attribute(params[:sort]) if params[:sort].present?
......@@ -55,7 +60,7 @@ class GroupMembersFinder < UnionFinder
members = members.filter_by_2fa(params[:two_factor])
end
members
by_created_at(members)
end
def can_manage_members
......
......@@ -2,6 +2,7 @@
class GroupMember < Member
include FromUnion
include CreatedAtFilterable
SOURCE_TYPE = 'Namespace'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment