Commit c2ac5bc3 authored by Aakriti Gupta's avatar Aakriti Gupta Committed by Bob Van Landuyt

Use CreatedAtFilter in GroupMemberFinder

parent 760c9334
# 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