View Source Glific.Groups (Glific v5.1.6)
The Groups context.
Link to this section Summary
Functions
Add permissioning specific to groups, in this case we want to restrict the visibility of groups that the user can see
Returns an %Ecto.Changeset{}
for tracking group changes.
Get the contacts ids for a specific group that have not opted out
Return the count of group contacts
Return the count of groups, using the same filter as list_groups
Creates a contact group.
Creates a group.
Creates a user group.
Delete contact groups
Deletes a group.
Delete group contacts
Delete group users
Delete user groups
Gets a single group.
Fetches all group ids in an organization
Get group by group name. Create the group if it does not exist
Given a group id, get stats on the contacts within this group based on bsp_status and also the total count
Returns the list of groups.
Returns the list of groups.
This function will load id by label
Updates a group.
Updates user groups entries
Return the count of group users
Link to this section Functions
@spec add_permission(Ecto.Query.t(), Glific.Users.User.t()) :: Ecto.Query.t()
Add permissioning specific to groups, in this case we want to restrict the visibility of groups that the user can see
@spec change_group(Glific.Groups.Group.t(), map()) :: Ecto.Changeset.t()
Returns an %Ecto.Changeset{}
for tracking group changes.
examples
Examples
iex> change_group(group)
%Ecto.Changeset{data: %Group{}}
@spec contact_ids(non_neg_integer()) :: [non_neg_integer()]
Get the contacts ids for a specific group that have not opted out
Return the count of group contacts
Return the count of groups, using the same filter as list_groups
@spec create_contact_group(map()) :: {:ok, Glific.Groups.ContactGroup.t()} | {:error, Ecto.Changeset.t()}
Creates a contact group.
examples
Examples
iex> create_contact_group(%{field: value})
{:ok, %Contact{}}
iex> create_contact_group(%{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec create_group(map()) :: {:ok, Glific.Groups.Group.t()} | {:error, Ecto.Changeset.t()}
Creates a group.
examples
Examples
iex> create_group(%{field: value})
{:ok, %Group{}}
iex> create_group(%{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec create_user_group(map()) :: {:ok, Glific.Groups.UserGroup.t()} | {:error, Ecto.Changeset.t()}
Creates a user group.
examples
Examples
iex> create_user_group(%{field: value})
{:ok, %User{}}
iex> create_user_group(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Delete contact groups
@spec delete_group(Glific.Groups.Group.t()) :: {:ok, Glific.Groups.Group.t()} | {:error, Ecto.Changeset.t()}
Deletes a group.
examples
Examples
iex> delete_group(group)
{:ok, %Group{}}
iex> delete_group(group)
{:error, %Ecto.Changeset{}}
Delete group contacts
Delete group users
Delete user groups
@spec get_group!(integer()) :: Glific.Groups.Group.t()
Gets a single group.
Raises Ecto.NoResultsError
if the Group does not exist.
examples
Examples
iex> get_group!(123)
%Group{}
iex> get_group!(456)
** (Ecto.NoResultsError)
@spec get_group_ids() :: list()
Fetches all group ids in an organization
@spec get_or_create_group_by_label(String.t(), non_neg_integer()) :: {:ok, Glific.Groups.Group.t()} | nil
Get group by group name. Create the group if it does not exist
@spec info_group_contacts(non_neg_integer()) :: map()
Given a group id, get stats on the contacts within this group based on bsp_status and also the total count
@spec list_groups(map(), boolean()) :: [Glific.Groups.Group.t()]
Returns the list of groups.
examples
Examples
iex> list_groups()
[%Group{}, ...]
@spec list_organizations_groups(map()) :: [Glific.Groups.Group.t()]
Returns the list of groups.
examples
Examples
iex> list_organizations_groups()
[%Group{}, ...]
This function will load id by label
@spec update_group(Glific.Groups.Group.t(), map()) :: {:ok, Glific.Groups.Group.t()} | {:error, Ecto.Changeset.t()}
Updates a group.
examples
Examples
iex> update_group(group, %{field: new_value})
{:ok, %Group{}}
iex> update_group(group, %{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec update_user_groups(map()) :: :ok
Updates user groups entries
Return the count of group users