Add user setting to provide location and show events near location on
homepage Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -14,7 +14,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Address do
|
||||
@spec search(map, map, map) :: {:ok, [Address.t()]}
|
||||
def search(
|
||||
_parent,
|
||||
%{query: query, locale: locale, page: _page, limit: _limit},
|
||||
%{query: query, locale: locale, page: _page, limit: _limit} = args,
|
||||
%{context: %{ip: ip}}
|
||||
) do
|
||||
geolix = Geolix.lookup(ip)
|
||||
@@ -25,7 +25,12 @@ defmodule Mobilizon.GraphQL.Resolvers.Address do
|
||||
_ -> nil
|
||||
end
|
||||
|
||||
addresses = Geospatial.service().search(query, lang: locale, country_code: country_code)
|
||||
addresses =
|
||||
Geospatial.service().search(query,
|
||||
lang: locale,
|
||||
country_code: country_code,
|
||||
type: Map.get(args, :type)
|
||||
)
|
||||
|
||||
{:ok, addresses}
|
||||
end
|
||||
|
||||
@@ -56,6 +56,15 @@ defmodule Mobilizon.GraphQL.Schema.AddressType do
|
||||
field(:origin_id, :string, description: "The address's original ID from the provider")
|
||||
end
|
||||
|
||||
@desc """
|
||||
A list of possible values for the type option to search an address.
|
||||
|
||||
Results may vary depending on the geocoding provider.
|
||||
"""
|
||||
enum :address_search_type do
|
||||
value(:administrative, description: "Administrative results (cities, regions,...)")
|
||||
end
|
||||
|
||||
object :address_queries do
|
||||
@desc "Search for an address"
|
||||
field :search_address, type: list_of(:address) do
|
||||
@@ -73,6 +82,8 @@ defmodule Mobilizon.GraphQL.Schema.AddressType do
|
||||
|
||||
arg(:limit, :integer, default_value: 10, description: "The limit of search results per page")
|
||||
|
||||
arg(:type, :address_search_type, description: "Filter by type of results")
|
||||
|
||||
resolve(&Address.search/3)
|
||||
end
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
|
||||
# field(:sessions, list_of(:session))
|
||||
|
||||
field(:updated_at, :datetime, description: "When the event was last updated")
|
||||
field(:created_at, :datetime, description: "When the event was created")
|
||||
field(:inserted_at, :datetime, description: "When the event was created")
|
||||
field(:options, :event_options, description: "The event options")
|
||||
end
|
||||
|
||||
|
||||
@@ -177,6 +177,10 @@ defmodule Mobilizon.GraphQL.Schema.UserType do
|
||||
description:
|
||||
"When does the user receives a notification about a new pending membership in one of the group they're admin for"
|
||||
)
|
||||
|
||||
field(:location, :location,
|
||||
description: "The user's preferred location, where they want to be suggested events"
|
||||
)
|
||||
end
|
||||
|
||||
@desc "The list of values the for pending notification settings"
|
||||
@@ -199,6 +203,25 @@ defmodule Mobilizon.GraphQL.Schema.UserType do
|
||||
)
|
||||
end
|
||||
|
||||
object :location do
|
||||
field(:range, :integer, description: "The range in kilometers the user wants to see events")
|
||||
|
||||
field(:geohash, :string, description: "A geohash representing the user's preferred location")
|
||||
|
||||
field(:name, :string, description: "A string describing the user's preferred location")
|
||||
end
|
||||
|
||||
@desc """
|
||||
The set of parameters needed to input a location
|
||||
"""
|
||||
input_object :location_input do
|
||||
field(:range, :integer, description: "The range in kilometers the user wants to see events")
|
||||
|
||||
field(:geohash, :string, description: "A geohash representing the user's preferred location")
|
||||
|
||||
field(:name, :string, description: "A string describing the user's preferred location")
|
||||
end
|
||||
|
||||
object :user_queries do
|
||||
@desc "Get an user"
|
||||
field :user, :user do
|
||||
@@ -343,6 +366,10 @@ defmodule Mobilizon.GraphQL.Schema.UserType do
|
||||
"When does the user receives a notification about a new pending membership in one of the group they're admin for"
|
||||
)
|
||||
|
||||
arg(:location, :location_input,
|
||||
description: "A geohash of the user's preferred location, where they want to see events"
|
||||
)
|
||||
|
||||
resolve(&User.set_user_setting/3)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user