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 participant.
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.
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
Returns the list of participations for an actor.
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.
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 participant.
Updates a session.
Updates a tag.
Updates a track.
Functions
@spec are_tags_linked?(Mobilizon.Events.Tag.t(), Mobilizon.Events.Tag.t()) :: boolean()
Checks whether two tags are linked or not.
@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()}]
@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.
Counts participant participants (participants with no extra role)
@spec count_participants_query(integer()) :: Ecto.Query.t()
@spec create_event(map()) :: {:ok, Mobilizon.Events.Event.t()} | {:error, Ecto.Changeset.t()} | {:error, :update | :write, Ecto.Changeset.t(), map()}
Creates an event.
@spec create_feed_token(map()) :: {:ok, Mobilizon.Events.FeedToken.t()} | {:error, Ecto.Changeset.t()}
Creates a feed token.
create_participant(attrs \\ %{}, update_event_participation_stats \\ true)
View SourceCreates a participant.
@spec create_session(map()) :: {:ok, Mobilizon.Events.Session.t()} | {:error, Ecto.Changeset.t()}
Creates a session.
@spec create_tag(map()) :: {:ok, Mobilizon.Events.Tag.t()} | {:error, Ecto.Changeset.t()}
Creates a tag.
@spec create_tag_relation(map()) :: {:ok, Mobilizon.Events.TagRelation.t()} | {:error, Ecto.Changeset.t()}
Creates a relation between two tags.
@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.
@spec delete_feed_token(Mobilizon.Events.FeedToken.t()) :: {:ok, Mobilizon.Events.FeedToken.t()} | {:error, Ecto.Changeset.t()}
Deletes a feed token.
@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.
@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.
@spec events_by_tags_query([integer()], integer()) :: Ecto.Query.t()
@spec filter_role(Ecto.Queryable.t(), [atom()] | atom()) :: Ecto.Query.t()
@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.
@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.
@spec get_event_by_uuid_with_preload(String.t()) :: Mobilizon.Events.Event.t() | nil
Gets an event by its UUID, with all associations loaded.
@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.
@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.
@spec get_participant(integer()) :: Mobilizon.Events.Participant.t() | nil
Gets a single participant.
Examples
iex> get_participant(123)
%Participant{}
iex> get_participant(456)
nil
@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.
@spec get_participant!(integer() | String.t()) :: Mobilizon.Events.Participant.t()
@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)
@spec get_participant_by_confirmation_token(String.t()) :: Mobilizon.Events.Participant.t() | nil
@spec get_participant_by_url(String.t()) :: Mobilizon.Events.Participant.t() | nil
Gets a participant by its URL.
@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.
@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.
@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.
@spec list_actors_participants_for_event(String.t()) :: [Mobilizon.Actors.Actor.t()]
@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
@spec list_anonymous_participants_for_event(String.t()) :: [ Mobilizon.Events.Participant.t() ]
List anonymous participations to an event
@spec list_drafts_for_user(integer(), integer() | nil, integer() | nil) :: Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())
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.
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.
@spec list_events_by_tags([Mobilizon.Events.Tag.t()], integer()) :: [ Mobilizon.Events.Event.t() ]
Returns the list of events with the same tags.
@spec list_feed_tokens_for_actor(Mobilizon.Actors.Actor.t()) :: [FeedTokens.t()]
Returns the list of feed tokens for an actor.
@spec list_feed_tokens_for_user(Mobilizon.Users.User.t()) :: [FeedTokens.t()]
Returns the list of feed tokens for an user.
@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}
@spec list_organized_events_for_actor( Mobilizon.Actors.Actor.t(), integer() | nil, integer() | nil ) :: Mobilizon.Storage.Page.t(Mobilizon.Events.Event.t())
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())
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}, ...]
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
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{}, ...]
@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.
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())
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.
@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.
@spec list_sessions_for_event(Mobilizon.Events.Event.t()) :: [ Mobilizon.Events.Session.t() ]
Returns the list of sessions for the event.
@spec list_sessions_for_track(Mobilizon.Events.Track.t()) :: [ Mobilizon.Events.Session.t() ]
Returns the list of sessions for the track.
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())
@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;
@spec list_tags(String.t() | nil, integer() | nil, integer() | nil) :: Mobilizon.Storage.Page.t(Mobilizon.Events.Tag.t())
Returns the list of tags.
@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.
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.
@spec participants_for_event_query(String.t(), [atom()]) :: Ecto.Query.t()
@spec stream_events_for_sitemap() :: Enum.t()
@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
@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.
@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.
@spec update_track(Mobilizon.Events.Track.t(), map()) :: {:ok, Mobilizon.Events.Track.t()} | {:error, Ecto.Changeset.t()}
Updates a track.