diff --git a/lib/graphql/resolvers/event.ex b/lib/graphql/resolvers/event.ex
index c375f0104..fe7aaec69 100644
--- a/lib/graphql/resolvers/event.ex
+++ b/lib/graphql/resolvers/event.ex
@@ -69,13 +69,31 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
@spec list_events(any(), map(), Absinthe.Resolution.t()) ::
{:ok, Page.t(Event.t())} | {:error, :events_max_limit_reached}
+ def list_events(
+ _parent,
+ %{
+ page: page,
+ limit: limit,
+ order_by: order_by,
+ direction: direction,
+ longevents: longevents,
+ location: location,
+ radius: radius
+ },
+ _resolution
+ )
+ when limit < @event_max_limit do
+ {:ok,
+ Events.list_events(page, limit, order_by, direction, true, longevents, location, radius)}
+ end
+
def list_events(
_parent,
%{page: page, limit: limit, order_by: order_by, direction: direction},
_resolution
)
when limit < @event_max_limit do
- {:ok, Events.list_events(page, limit, order_by, direction)}
+ {:ok, Events.list_events(page, limit, order_by, direction, true)}
end
def list_events(_parent, %{page: _page, limit: _limit}, _resolution) do
diff --git a/lib/graphql/schema/event.ex b/lib/graphql/schema/event.ex
index e2961794d..4ecd682fe 100644
--- a/lib/graphql/schema/event.ex
+++ b/lib/graphql/schema/event.ex
@@ -375,6 +375,13 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
object :event_queries do
@desc "Get all events"
field :events, :paginated_event_list do
+ arg(:location, :string, default_value: nil, description: "A geohash for coordinates")
+
+ arg(:radius, :float,
+ default_value: nil,
+ description: "Radius around the location to search in"
+ )
+
arg(:page, :integer, default_value: 1, description: "The page in the paginated event list")
arg(:limit, :integer, default_value: 10, description: "The limit of events per page")
@@ -388,6 +395,11 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
description: "Direction for the sort"
)
+ arg(:longevents, :boolean,
+ default_value: nil,
+ description: "if mention filter in or out long events"
+ )
+
middleware(Rajska.QueryAuthorization, permit: :all)
resolve(&Event.list_events/3)
diff --git a/lib/mobilizon/events/events.ex b/lib/mobilizon/events/events.ex
index 1009a0197..4d68b9d41 100644
--- a/lib/mobilizon/events/events.ex
+++ b/lib/mobilizon/events/events.ex
@@ -359,19 +359,34 @@ defmodule Mobilizon.Events do
@doc """
Returns the list of events.
"""
- @spec list_events(integer | nil, integer | nil, atom, atom, boolean) :: Page.t(Event.t())
+ @spec list_events(
+ integer | nil,
+ integer | nil,
+ atom,
+ atom,
+ boolean,
+ boolean | nil,
+ string | nil,
+ float | nil
+ ) :: Page.t(Event.t())
def list_events(
page \\ nil,
limit \\ nil,
sort \\ :begins_on,
direction \\ :asc,
- is_future \\ true
+ is_future \\ true,
+ longevents \\ nil,
+ location \\ nil,
+ radius \\ nil
) do
Event
|> distinct([e], [{^direction, ^sort}, asc: e.id])
|> preload([:organizer_actor, :participants])
|> sort(sort, direction)
+ |> maybe_join_address(%{location: location, radius: radius})
+ |> events_for_location(%{location: location, radius: radius})
|> filter_future_events(is_future)
+ |> events_for_longevents(longevents)
|> filter_public_visibility()
|> filter_draft()
|> filter_cancelled_events()
@@ -572,7 +587,7 @@ defmodule Mobilizon.Events do
|> events_for_search_query()
|> events_for_begins_on(Map.get(args, :begins_on, DateTime.utc_now()))
|> events_for_ends_on(Map.get(args, :ends_on))
- |> events_for_longevents(args)
+ |> events_for_longevents(Map.get(args, :longevents))
|> events_for_category(args)
|> events_for_categories(args)
|> events_for_languages(args)
@@ -1379,15 +1394,13 @@ defmodule Mobilizon.Events do
end
end
- @spec events_for_longevents(Ecto.Queryable.t(), map()) :: Ecto.Query.t()
- defp events_for_longevents(query, args) do
+ @spec events_for_longevents(Ecto.Queryable.t(), Boolean.t() | nil) :: Ecto.Query.t()
+ defp events_for_longevents(query, longevents) do
duration = Config.get([:instance, :duration_of_long_event], 0)
if duration <= 0 do
query
else
- longevents = Map.get(args, :longevents)
-
case longevents do
nil ->
query
diff --git a/package-lock.json b/package-lock.json
index 2c293227e..47e154224 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -6,7 +6,7 @@
"packages": {
"": {
"name": "mobilizon",
- "version": "4.1.0",
+ "version": "5.0.0-beta.1",
"hasInstallScript": true,
"dependencies": {
"@apollo/client": "^3.3.16",
@@ -16,7 +16,7 @@
"@fullcalendar/daygrid": "^6.1.10",
"@fullcalendar/interaction": "^6.1.10",
"@fullcalendar/vue3": "^6.1.10",
- "@oruga-ui/oruga-next": "^0.8.10",
+ "@oruga-ui/oruga-next": "0.8.12",
"@oruga-ui/theme-oruga": "^0.2.0",
"@sentry/tracing": "^7.1",
"@sentry/vue": "^7.1",
@@ -3138,9 +3138,9 @@
"dev": true
},
"node_modules/@oruga-ui/oruga-next": {
- "version": "0.8.10",
- "resolved": "https://registry.npmjs.org/@oruga-ui/oruga-next/-/oruga-next-0.8.10.tgz",
- "integrity": "sha512-ETPSoGZu1parbj8C3V2ZojQnN4ptQMiJEwS9Hx44NcaDzu4q/FDsYkKYiz6G9kx8cDceXXxvydfOUpZePVVdzw==",
+ "version": "0.8.12",
+ "resolved": "https://registry.npmjs.org/@oruga-ui/oruga-next/-/oruga-next-0.8.12.tgz",
+ "integrity": "sha512-I1jcsTA4J6HQdNpSWgK4cNSqv1cHsghQGtJ12p0yXDSJseek0Y8f4vf9+tDRtfONzWHuRyWUGcHIfePsRKVbiQ==",
"peerDependencies": {
"vue": "^3.0.0"
}
diff --git a/src/components/Home/SearchFields.vue b/src/components/Home/SearchFields.vue
index ed04c586e..afd74e414 100644
--- a/src/components/Home/SearchFields.vue
+++ b/src/components/Home/SearchFields.vue
@@ -1,7 +1,7 @@