View Source Glific.Tags (Glific v5.1.6)
The Tags Context, which encapsulates and manages tags and the related join tables.
Link to this section Summary
Functions
Returns an %Ecto.Changeset{}
for tracking contact changes.
Returns an %Ecto.Changeset{}
for tracking message changes.
Returns an %Ecto.Changeset{}
for tracking tag changes.
Return the count of tags, using the same filter as list_tags
Creates a contact.
Creates a message tag
Creates a tag.
Creates a template tag.
Deletes a list of contact tags, each tag attached to the same contact
In Join tables we rarely use the table id. We always know the object ids and hence more convenient to delete an entry via its object ids. We will generalize this function and move it to Repo.ex when we get a better handle on how to do so :)
Deletes a tag.
Deletes a list of template tags, each tag attached to the same template
Given a shortcode of tag, retrieve all the children for the tag
Gets a single contact.
Gets a single message.
Gets a single tag.
Given a tag id or a list of tag ids, retrieve all the ancestors for the list_tags
Converts all tag kewords into the map where keyword is the key and tag id is the value
Returns the list of tags.
Remove a specific tag from contact messages
Filter all the status tag and returns as a map
Updates a contact tag.
Updates a message tag.
Updates a tag.
Link to this section Functions
@spec change_contact_tag(Glific.Tags.ContactTag.t(), map()) :: Ecto.Changeset.t()
Returns an %Ecto.Changeset{}
for tracking contact changes.
examples
Examples
iex> change_contact_tag(contact_tag)
%Ecto.Changeset{data: %ContactTag{}}
@spec change_message_tag(Glific.Tags.MessageTag.t(), map()) :: Ecto.Changeset.t()
Returns an %Ecto.Changeset{}
for tracking message changes.
examples
Examples
iex> change_message_tag(message_tag)
%Ecto.Changeset{data: %MessageTag{}}
@spec change_tag(Glific.Tags.Tag.t(), map()) :: Ecto.Changeset.t()
Returns an %Ecto.Changeset{}
for tracking tag changes.
examples
Examples
iex> change_tag(tag)
%Ecto.Changeset{data: %Tag{}}
Return the count of tags, using the same filter as list_tags
@spec create_contact_tag(map()) :: {:ok, Glific.Tags.ContactTag.t()} | {:error, Ecto.Changeset.t()}
Creates a contact.
examples
Examples
iex> create_contact_tag(%{field: value})
{:ok, %Contact{}}
iex> create_contact_tag(%{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec create_message_tag(map()) :: {:ok, Glific.Tags.MessageTag.t()} | {:error, Ecto.Changeset.t()}
Creates a message tag
examples
Examples
iex> create_message_tag(%{field: value}) {:ok, %Message{}}
iex> create_message_tag(%{field: bad_value}) {:error, %Ecto.Changeset{}}
@spec create_tag(map()) :: {:ok, Glific.Tags.Tag.t()} | {:error, Ecto.Changeset.t()}
Creates a tag.
examples
Examples
iex> create_tag(%{field: value})
{:ok, %Tag{}}
iex> create_tag(%{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec create_template_tag(map()) :: {:ok, Glific.Tags.TemplateTag.t()} | {:error, Ecto.Changeset.t()}
Creates a template tag.
examples
Examples
iex> create_template_tag(%{field: value})
{:ok, %Contact{}}
iex> create_template_tag(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Deletes a list of contact tags, each tag attached to the same contact
@spec delete_message_tag_by_ids(integer(), [], non_neg_integer()) :: {integer(), nil | [term()]}
In Join tables we rarely use the table id. We always know the object ids and hence more convenient to delete an entry via its object ids. We will generalize this function and move it to Repo.ex when we get a better handle on how to do so :)
@spec delete_tag(Glific.Tags.Tag.t()) :: {:ok, Glific.Tags.Tag.t()} | {:error, Ecto.Changeset.t()}
Deletes a tag.
examples
Examples
iex> delete_tag(tag)
{:ok, %Tag{}}
iex> delete_tag(tag)
{:error, %Ecto.Changeset{}}
Deletes a list of template tags, each tag attached to the same template
@spec get_all_children(String.t(), non_neg_integer()) :: [Glific.Tags.Tag.t()]
Given a shortcode of tag, retrieve all the children for the tag
@spec get_contact_tag!(integer()) :: Glific.Tags.ContactTag.t()
Gets a single contact.
Raises Ecto.NoResultsError
if the Contact does not exist.
examples
Examples
iex> get_contact_tag!(123)
%Contact{}
iex> get_contact_tag!(456)
** (Ecto.NoResultsError)
@spec get_message_tag!(integer()) :: Glific.Tags.MessageTag.t()
Gets a single message.
Raises Ecto.NoResultsError
if the Message does not exist.
examples
Examples
iex> get_message_tag!(123)
%Message{}
iex> get_message_tag!(456)
** (Ecto.NoResultsError)
@spec get_tag!(integer()) :: Glific.Tags.Tag.t()
Gets a single tag.
Raises Ecto.NoResultsError
if the Tag does not exist.
examples
Examples
iex> get_tag!(123)
%Tag{}
iex> get_tag!(456)
** (Ecto.NoResultsError)
@spec include_all_ancestors(non_neg_integer() | [non_neg_integer()]) :: [ non_neg_integer() ]
Given a tag id or a list of tag ids, retrieve all the ancestors for the list_tags
Converts all tag kewords into the map where keyword is the key and tag id is the value
@spec list_tags(map()) :: [Glific.Tags.Tag.t()]
Returns the list of tags.
examples
Examples
iex> list_tags()
[%Tag{}, ...]
remove_tag_from_all_message(contact_id, tag_shortcode, organization_id, publish \\ true)
View Source@spec remove_tag_from_all_message(integer(), String.t(), non_neg_integer(), boolean()) :: list()
@spec remove_tag_from_all_message( integer(), [String.t()], non_neg_integer(), boolean() ) :: list()
Remove a specific tag from contact messages
Filter all the status tag and returns as a map
@spec update_contact_tag(Glific.Tags.ContactTag.t(), map()) :: {:ok, Glific.Tags.ContactTag.t()} | {:error, Ecto.Changeset.t()}
Updates a contact tag.
examples
Examples
iex> update_contact_tag(contact_tag, %{field: new_value})
{:ok, %ContactTag{}}
iex> update_contact_tag(contact_tag, %{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec update_message_tag(Glific.Tags.MessageTag.t(), map()) :: {:ok, Glific.Tags.MessageTag.t()} | {:error, Ecto.Changeset.t()}
Updates a message tag.
examples
Examples
iex> update_message_tag(message_tag, %{field: new_value})
{:ok, %MessageTag{}}
iex> update_message_tag(message_tag, %{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec update_tag(Glific.Tags.Tag.t(), map()) :: {:ok, Glific.Tags.Tag.t()} | {:error, Ecto.Changeset.t()}
Updates a tag.
examples
Examples
iex> update_tag(tag, %{field: new_value})
{:ok, %Tag{}}
iex> update_tag(tag, %{field: bad_value})
{:error, %Ecto.Changeset{}}