View Source Mobilizon.Events (Mobilizon v5.0.0-beta.1)

The Events context.

Summary

Functions

Checks whether two tags are linked or not.

Builds a page struct for events by their name.

Returns the number of participations for all local events

Counts all events.

Counts local events.

Counts participant participants (participants with no extra role)

Creates an event.

Creates a feed token.

Creates a session.

Creates a tag.

Creates a relation between two tags.

Creates a track.

Deletes an event.

Deletes a feed token.

Deletes a participant.

Deletes a session.

Deletes a tag.

Removes a tag relation.

Deletes a track.

Finds close events to coordinates. Radius is in meters and defaults to 50km.

Gets the default participant role depending on the event join options.

Gets a single event.

Gets a single event. Raises Ecto.NoResultsError if the event does not exist.

Gets an event by its URL.

Gets an event by its URL. Raises Ecto.NoResultsError if the event does not exist.

Gets an event by its UUID, with all associations loaded.

Gets a single event, with all associations loaded.

Gets a single event, with all associations loaded. Raises Ecto.NoResultsError if the event does not exist.

Gets a single feed token.

Gets a single participant.

Gets a single participation for an event and actor.

Gets a single participation for an event and actor.

Gets a participant by its URL.

Gets an event by its URL, with all associations loaded. Raises Ecto.NoResultsError if the event does not exist.

Gets a public event by its UUID, with all associations loaded.

Gets a single session. Raises Ecto.NoResultsError if the session does not exist.

Gets a single tag.

Gets a single tag. Raises Ecto.NoResultsError if the tag does not exist.

Gets a tag by its slug.

Gets a tag by its title.

Gets a single track. Raises Ecto.NoResultsError if the track does not exist.

Gets an actor's eventual upcoming public event.

Returns the whole list of participants for an event. Default behaviour is to not return :not_approved or :not_confirmed participants

List anonymous participations to an event

Returns the list of participations for an actor.

Returns the list of events with the same tags.

Returns the list of feed tokens for an actor.

Returns the list of feed tokens for an user.

List emails for local users (including anonymous ones) participating to an event

Returns the list of organizers participants for an event.

Returns the list of participants for an event. Default behaviour is to not return :not_approved or :not_confirmed participants

Lists public events for the actor, with all associations loaded.

Lists public upcoming events for the actor, with all associations loaded.

Returns the list of event participation requests for an actor.

Returns the list of sessions.

Returns the list of sessions for the event.

Returns the list of sessions for the track.

Returns the tags neighbors for a given tag

Returns the list of tags for the event.

Returns the list of tracks.

Returns the list of upcoming participations for an actor.

Updates an event.

Updates a session.

Updates a tag.

Updates a track.

Functions

Link to this function

are_tags_linked?(tag1, tag2)

View Source
@spec are_tags_linked?(Mobilizon.Events.Tag.t(), Mobilizon.Events.Tag.t()) ::
  boolean()

Checks whether two tags are linked or not.

Link to this function

build_events_for_search(args, page \\ nil, limit \\ nil)

View Source
@spec build_events_for_search(map(), integer() | nil, integer() | nil) ::
  Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())

Builds a page struct for events by their name.

@spec category_statistics() :: [{String.t(), non_neg_integer()}]
Link to this function

check_if_event_has_instance_follow(event_uri, follower_actor_id)

View Source
@spec check_if_event_has_instance_follow(String.t(), integer()) :: boolean()
Link to this function

count_confirmed_participants_for_local_events()

View Source
@spec count_confirmed_participants_for_local_events() :: integer()

Returns the number of participations for all local events

@spec count_events() :: integer()

Counts all events.

@spec count_local_events() :: integer()

Counts local events.

Link to this function

count_participant_participants(event_id)

View Source
@spec count_participant_participants(integer() | String.t()) :: integer()

Counts participant participants (participants with no extra role)

Link to this function

count_participants_query(event_id)

View Source
@spec count_participants_query(integer()) :: Ecto.Query.t()
Link to this function

create_event(attrs \\ %{})

View Source
@spec create_event(map()) ::
  {:ok, Mobilizon.Events.Event.t()}
  | {:error, Ecto.Changeset.t()}
  | {:error, :update | :write, Ecto.Changeset.t(), map()}

Creates an event.

Link to this function

create_feed_token(attrs \\ %{})

View Source
@spec create_feed_token(map()) ::
  {:ok, Mobilizon.Events.FeedToken.t()} | {:error, Ecto.Changeset.t()}

Creates a feed token.

Link to this function

create_participant(attrs \\ %{}, update_event_participation_stats \\ true)

View Source

Creates a participant.

Link to this function

create_session(attrs \\ %{})

View Source
@spec create_session(map()) ::
  {:ok, Mobilizon.Events.Session.t()} | {:error, Ecto.Changeset.t()}

Creates a session.

Link to this function

create_tag(attrs \\ %{})

View Source
@spec create_tag(map()) ::
  {:ok, Mobilizon.Events.Tag.t()} | {:error, Ecto.Changeset.t()}

Creates a tag.

Link to this function

create_tag_relation(attrs)

View Source
@spec create_tag_relation(map()) ::
  {:ok, Mobilizon.Events.TagRelation.t()} | {:error, Ecto.Changeset.t()}

Creates a relation between two tags.

Link to this function

create_track(attrs \\ %{})

View Source
@spec create_track(map()) ::
  {:ok, Mobilizon.Events.Track.t()} | {:error, Ecto.Changeset.t()}

Creates a track.

@spec delete_event(Mobilizon.Events.Event.t()) ::
  {:ok, Mobilizon.Events.Event.t()} | {:error, Ecto.Changeset.t()}

Deletes an event.

Link to this function

delete_feed_token(feed_token)

View Source
@spec delete_feed_token(Mobilizon.Events.FeedToken.t()) ::
  {:ok, Mobilizon.Events.FeedToken.t()} | {:error, Ecto.Changeset.t()}

Deletes a feed token.

Link to this function

delete_participant(participant)

View Source
@spec delete_participant(Mobilizon.Events.Participant.t()) ::
  {:ok, %{participant: Mobilizon.Events.Participant.t()}}
  | {:error, :participant | :update_event_participation_stats,
     Ecto.Changeset.t(), map()}

Deletes a participant.

@spec delete_session(Mobilizon.Events.Session.t()) ::
  {:ok, Mobilizon.Events.Session.t()} | {:error, Ecto.Changeset.t()}

Deletes a session.

@spec delete_tag(Mobilizon.Events.Tag.t()) ::
  {:ok, Mobilizon.Events.Tag.t()} | {:error, Ecto.Changeset.t()}

Deletes a tag.

Link to this function

delete_tag_relation(tag_relation)

View Source
@spec delete_tag_relation(Mobilizon.Events.TagRelation.t()) ::
  {:ok, Mobilizon.Events.TagRelation.t()} | {:error, Ecto.Changeset.t()}

Removes a tag relation.

@spec delete_track(Mobilizon.Events.Track.t()) ::
  {:ok, Mobilizon.Events.Track.t()} | {:error, Ecto.Changeset.t()}

Deletes a track.

Link to this function

events_by_tags_query(tags_ids, limit)

View Source
@spec events_by_tags_query([integer()], integer()) :: Ecto.Query.t()
Link to this function

filter_role(query, roles)

View Source
@spec filter_role(Ecto.Queryable.t(), [atom()] | atom()) :: Ecto.Query.t()
Link to this function

find_close_events(lon, lat, radius \\ 50000)

View Source
@spec find_close_events(float(), float(), non_neg_integer()) :: [
  Mobilizon.Events.Event.t()
]

Finds close events to coordinates. Radius is in meters and defaults to 50km.

Link to this function

get_default_participant_role(event)

View Source
@spec get_default_participant_role(Mobilizon.Events.Event.t()) ::
  :participant | :not_approved

Gets the default participant role depending on the event join options.

@spec get_event(integer() | String.t()) ::
  {:ok, Mobilizon.Events.Event.t()} | {:error, :event_not_found}

Gets a single event.

@spec get_event!(integer() | String.t()) :: Mobilizon.Events.Event.t()

Gets a single event. Raises Ecto.NoResultsError if the event does not exist.

@spec get_event_by_url(String.t()) :: Mobilizon.Events.Event.t() | nil

Gets an event by its URL.

@spec get_event_by_url!(String.t()) :: Mobilizon.Events.Event.t()

Gets an event by its URL. Raises Ecto.NoResultsError if the event does not exist.

Link to this function

get_event_by_uuid_with_preload(uuid)

View Source
@spec get_event_by_uuid_with_preload(String.t()) :: Mobilizon.Events.Event.t() | nil

Gets an event by its UUID, with all associations loaded.

Link to this function

get_event_with_preload(id)

View Source
@spec get_event_with_preload(integer() | String.t()) ::
  {:ok, Mobilizon.Events.Event.t()} | {:error, :event_not_found}

Gets a single event, with all associations loaded.

Link to this function

get_event_with_preload!(id)

View Source
@spec get_event_with_preload!(integer() | String.t()) :: Mobilizon.Events.Event.t()

Gets a single event, with all associations loaded. Raises Ecto.NoResultsError if the event does not exist.

@spec get_feed_token(String.t()) :: Mobilizon.Events.FeedToken.t() | nil

Gets a single feed token.

Link to this function

get_participant(participant_id)

View Source
@spec get_participant(integer()) :: Mobilizon.Events.Participant.t() | nil

Gets a single participant.

Examples

iex> get_participant(123)
%Participant{}

iex> get_participant(456)
nil
Link to this function

get_participant(event_id, actor_id, params \\ %{})

View Source
@spec get_participant(integer() | String.t(), integer() | String.t(), map()) ::
  {:ok, Mobilizon.Events.Participant.t()} | {:error, :participant_not_found}

Gets a single participation for an event and actor.

Link to this function

get_participant!(participant_id)

View Source
@spec get_participant!(integer() | String.t()) :: Mobilizon.Events.Participant.t()
Link to this function

get_participant!(event_id, actor_id)

View Source
@spec get_participant!(integer() | String.t(), integer() | String.t()) ::
  Mobilizon.Events.Participant.t()

Gets a single participation for an event and actor.

Raises Ecto.NoResultsError if the Participant does not exist.

Examples

iex> get_participant!(123, 19)
%Participant{}

iex> get_participant!(456, 5)
** (Ecto.NoResultsError)
Link to this function

get_participant_by_confirmation_token(confirmation_token)

View Source
@spec get_participant_by_confirmation_token(String.t()) ::
  Mobilizon.Events.Participant.t() | nil
Link to this function

get_participant_by_url(url)

View Source
@spec get_participant_by_url(String.t()) :: Mobilizon.Events.Participant.t() | nil

Gets a participant by its URL.

Link to this function

get_public_event_by_url_with_preload!(url)

View Source
@spec get_public_event_by_url_with_preload!(String.t()) :: Mobilizon.Events.Event.t()

Gets an event by its URL, with all associations loaded. Raises Ecto.NoResultsError if the event does not exist.

Link to this function

get_public_event_by_uuid_with_preload(uuid)

View Source
@spec get_public_event_by_uuid_with_preload(String.t()) ::
  Mobilizon.Events.Event.t() | nil

Gets a public event by its UUID, with all associations loaded.

@spec get_session!(integer() | String.t()) :: Mobilizon.Events.Session.t()

Gets a single session. Raises Ecto.NoResultsError if the session does not exist.

@spec get_tag(integer() | String.t()) :: Mobilizon.Events.Tag.t() | nil

Gets a single tag.

@spec get_tag!(integer() | String.t()) :: Mobilizon.Events.Tag.t()

Gets a single tag. Raises Ecto.NoResultsError if the tag does not exist.

@spec get_tag_by_slug(String.t()) :: Mobilizon.Events.Tag.t() | nil

Gets a tag by its slug.

@spec get_tag_by_title(String.t()) :: Mobilizon.Events.Tag.t() | nil

Gets a tag by its title.

@spec get_track!(integer() | String.t()) :: Mobilizon.Events.Track.t()

Gets a single track. Raises Ecto.NoResultsError if the track does not exist.

Link to this function

get_upcoming_public_event_for_actor(actor, not_event_uuid \\ nil)

View Source
@spec get_upcoming_public_event_for_actor(
  Mobilizon.Actors.Actor.t(),
  String.t() | nil
) ::
  Mobilizon.Events.Event.t() | nil

Gets an actor's eventual upcoming public event.

Link to this function

list_actors_participants_for_event(id)

View Source
@spec list_actors_participants_for_event(String.t()) :: [Mobilizon.Actors.Actor.t()]
Link to this function

list_all_participants_for_event(id, roles \\ [])

View Source
@spec list_all_participants_for_event(String.t(), [atom()]) :: [
  Mobilizon.Events.Participant.t()
]

Returns the whole list of participants for an event. Default behaviour is to not return :not_approved or :not_confirmed participants

Link to this function

list_anonymous_participants_for_event(event_id)

View Source
@spec list_anonymous_participants_for_event(String.t()) :: [
  Mobilizon.Events.Participant.t()
]

List anonymous participations to an event

Link to this function

list_drafts_for_user(user_id, page \\ nil, limit \\ nil)

View Source
@spec list_drafts_for_user(integer(), integer() | nil, integer() | nil) ::
  Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())
Link to this function

list_event_participations_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@spec list_event_participations_for_actor(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) ::
  Mobilizon.Storage.Page.t(Mobilizon.Events.Participant.t())

Returns the list of participations for an actor.

Link to this function

list_events(page \\ nil, limit \\ nil, sort \\ :begins_on, direction \\ :asc, is_future \\ true)

View Source
@spec list_events(integer() | nil, integer() | nil, atom(), atom(), boolean()) ::
  Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())

Returns the list of events.

Link to this function

list_events_by_tags(tags, limit \\ 2)

View Source
@spec list_events_by_tags([Mobilizon.Events.Tag.t()], integer()) :: [
  Mobilizon.Events.Event.t()
]

Returns the list of events with the same tags.

Link to this function

list_feed_tokens_for_actor(actor)

View Source
@spec list_feed_tokens_for_actor(Mobilizon.Actors.Actor.t()) :: [FeedTokens.t()]

Returns the list of feed tokens for an actor.

Link to this function

list_feed_tokens_for_user(user)

View Source
@spec list_feed_tokens_for_user(Mobilizon.Users.User.t()) :: [FeedTokens.t()]

Returns the list of feed tokens for an user.

Link to this function

list_local_emails_user_participants_for_event_query(event_id)

View Source
@spec list_local_emails_user_participants_for_event_query(String.t()) ::
  Ecto.Query.t()

List emails for local users (including anonymous ones) participating to an event

Returns {participation, actor, user, user_settings}

Link to this function

list_organized_events_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@spec list_organized_events_for_actor(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) ::
  Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())
Link to this function

list_organized_events_for_group(actor, visibility \\ :public, after_datetime \\ nil, before_datetime \\ nil, order_by \\ nil, order_direction \\ nil, page \\ nil, limit \\ nil)

View Source
@spec list_organized_events_for_group(
  Mobilizon.Actors.Actor.t(),
  :public | :all,
  DateTime.t() | nil,
  DateTime.t() | nil,
  atom() | nil,
  atom() | nil,
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())
Link to this function

list_organizers_participants_for_event(event_id, page \\ nil, limit \\ nil)

View Source
@spec list_organizers_participants_for_event(
  integer() | String.t(),
  integer() | nil,
  integer() | nil
) :: [Mobilizon.Events.Participant.t()]

Returns the list of organizers participants for an event.

Examples

iex> list_organizers_participants_for_event(id)
[%Participant{role: :creator}, ...]
Link to this function

list_participants_for_event(id, roles \\ [], page \\ nil, limit \\ nil)

View Source
@spec list_participants_for_event(
  String.t(),
  [atom()],
  integer() | nil,
  integer() | nil
) ::
  Mobilizon.Storage.Page.t(Mobilizon.Events.Participant.t())

Returns the list of participants for an event. Default behaviour is to not return :not_approved or :not_confirmed participants

Link to this function

list_participations_for_user(user_id, after_datetime, before_datetime, page, limit)

View Source
@spec list_participations_for_user(
  integer(),
  DateTime.t() | nil,
  DateTime.t() | nil,
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Events.Participant.t())

Returns the list of participations for an actor.

Default behaviour is to not return :not_approved participants

Examples

iex> list_event_participations_for_user(5)
[%Participant{}, ...]
Link to this function

list_public_events_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@spec list_public_events_for_actor(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) ::
  Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())

Lists public events for the actor, with all associations loaded.

Link to this function

list_public_local_events(page \\ nil, limit \\ nil, sort \\ nil, direction \\ nil)

View Source
@spec list_public_local_events(
  integer() | nil,
  integer() | nil,
  atom() | nil,
  atom() | nil
) ::
  Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())
Link to this function

list_public_upcoming_events_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@spec list_public_upcoming_events_for_actor(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())

Lists public upcoming events for the actor, with all associations loaded.

Link to this function

list_requests_for_actor(actor)

View Source
@spec list_requests_for_actor(Mobilizon.Actors.Actor.t()) :: [
  Mobilizon.Events.Participant.t()
]

Returns the list of event participation requests for an actor.

@spec list_sessions() :: [Mobilizon.Events.Session.t()]

Returns the list of sessions.

Link to this function

list_sessions_for_event(event)

View Source
@spec list_sessions_for_event(Mobilizon.Events.Event.t()) :: [
  Mobilizon.Events.Session.t()
]

Returns the list of sessions for the event.

Link to this function

list_sessions_for_track(track)

View Source
@spec list_sessions_for_track(Mobilizon.Events.Track.t()) :: [
  Mobilizon.Events.Session.t()
]

Returns the list of sessions for the track.

Link to this function

list_simple_organized_events_for_group(actor, page \\ nil, limit \\ nil)

View Source
@spec list_simple_organized_events_for_group(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())
Link to this function

list_tag_neighbors(tag, relation_minimum \\ 1, limit \\ 10)

View Source
@spec list_tag_neighbors(Mobilizon.Events.Tag.t(), integer(), integer()) :: [
  Mobilizon.Events.Tag.t()
]

Returns the tags neighbors for a given tag

We can't rely on the single many_to_many relation since we also want tags that link to our tag, not just tags linked by this one.

The SQL query looks like this:

SELECT * FROM tags t
RIGHT JOIN (
  SELECT weight, link_id AS id
  FROM tag_relations t2
  WHERE tag_id = 1
  UNION ALL
  SELECT tag_id AS id, weight
  FROM tag_relations t2
  WHERE link_id = 1
) tr
ON t.id = tr.id
ORDER BY tr.weight
DESC;
Link to this function

list_tags(filter \\ nil, page \\ nil, limit \\ nil)

View Source
@spec list_tags(String.t() | nil, integer() | nil, integer() | nil) ::
  Mobilizon.Storage.Page.t(Mobilizon.Events.Tag.t())

Returns the list of tags.

Link to this function

list_tags_for_event(event_id, page \\ nil, limit \\ nil)

View Source
@spec list_tags_for_event(integer() | String.t(), integer() | nil, integer() | nil) ::
  [
    Mobilizon.Events.Tag.t()
  ]

Returns the list of tags for the event.

@spec list_tracks() :: [Mobilizon.Events.Track.t()]

Returns the list of tracks.

Link to this function

list_upcoming_event_participations_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@spec list_upcoming_event_participations_for_actor(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Events.Participant.t())

Returns the list of upcoming participations for an actor.

Link to this macro

matching_event_ids_and_ranks(search_string)

View Source (macro)
Link to this function

participant_for_event_export_query(id, roles)

View Source
Link to this function

participants_for_event_query(id, roles \\ [])

View Source
@spec participants_for_event_query(String.t(), [atom()]) :: Ecto.Query.t()
Link to this function

stream_events(local \\ true, chunk_size \\ 500)

View Source
@spec stream_events(boolean() | nil, integer()) :: Enum.t()
Link to this function

stream_events_for_sitemap()

View Source
@spec stream_events_for_sitemap() :: Enum.t()
Link to this function

update_event(old_event, attrs)

View Source
@spec update_event(Mobilizon.Events.Event.t(), map()) ::
  {:ok, Mobilizon.Events.Event.t()}
  | {:error, Ecto.Changeset.t()}
  | {:error, :update | :write, Ecto.Changeset.t(), map()}

Updates an event.

We start by updating the event and then insert a first participant if the event is not a draft anymore

Link to this function

update_participant(participant, attrs)

View Source
@spec update_participant(Mobilizon.Events.Participant.t(), map()) ::
  {:ok, Mobilizon.Events.Participant.t()}
  | {:error, :participant | :update_event_participation_stats,
     Ecto.Changeset.t(), map()}

Updates a participant.

Link to this function

update_session(session, attrs)

View Source
@spec update_session(Mobilizon.Events.Session.t(), map()) ::
  {:ok, Mobilizon.Events.Session.t()} | {:error, Ecto.Changeset.t()}

Updates a session.

@spec update_tag(Mobilizon.Events.Tag.t(), map()) ::
  {:ok, Mobilizon.Events.Tag.t()} | {:error, Ecto.Changeset.t()}

Updates a tag.

Link to this function

update_track(track, attrs)

View Source
@spec update_track(Mobilizon.Events.Track.t(), map()) ::
  {:ok, Mobilizon.Events.Track.t()} | {:error, Ecto.Changeset.t()}

Updates a track.

Link to this function

user_moderator_for_event?(user_id, event_id)

View Source
@spec user_moderator_for_event?(integer() | String.t(), integer() | String.t()) ::
  boolean()