Class: GroupsFinder

Inherits:
UnionFinder show all
Includes:
CustomAttributesFilter, Namespaces::GroupsFilter
Defined in:
app/finders/groups_finder.rb

Overview

GroupsFinder

Used to filter Groups by a set of params

Arguments:

current_user - which user is requesting groups
params:
  owned: boolean
  parent: Group
  all_available: boolean (defaults to true)
  min_access_level: integer
  search: string
  exclude_group_ids: array of integers
  filter_group_ids: array of integers - only include groups from the specified list of ids
  include_parent_descendants: boolean (defaults to false) - includes descendant groups when
                              filtering by parent. The parent param must be present.
  include_parent_shared_groups: boolean (defaults to false) - includes shared groups of a parent group
                              when filtering by parent.
                              Both parent and include_parent_descendants params must be present.
  include_ancestors: boolean (defaults to true)
  organization: Scope the groups to the Organizations::Organization

Users with full private access can see all groups. The ‘owned` and `parent` params can be used to restrict the groups that are returned.

Anonymous users will never return any ‘owned` groups. They will return all public groups instead, even if `all_available` is set to false.

Direct Known Subclasses

Organizations::GroupsFinder

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CustomAttributesFilter

#by_custom_attributes

Methods inherited from UnionFinder

#find_union

Constructor Details

#initialize(current_user = nil, params = {}) ⇒ GroupsFinder

Returns a new instance of GroupsFinder.



36
37
38
39
# File 'app/finders/groups_finder.rb', line 36

def initialize(current_user = nil, params = {})
  @current_user = current_user
  @params = params
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



34
35
36
# File 'app/finders/groups_finder.rb', line 34

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params.



34
35
36
# File 'app/finders/groups_finder.rb', line 34

def params
  @params
end

Instance Method Details

#executeObject



41
42
43
44
45
46
# File 'app/finders/groups_finder.rb', line 41

def execute
  # filtered_groups can contain an array of scopes, so these
  # are combined into a single query using UNION.
  groups = find_union(filtered_groups, Group)
  sort(groups).with_route
end