Is your feature request related to a problem? Please describe.
Admins need to see individual groups needs, but also need to able to view aggregated needs lists by geographical region.
Describe the solution you'd like
a GraphQL query that implements this feature. Given a "region" and a given UTC date, the query should return a list of needs that is the aggregation of needs for each group that falls within the region for the given date range.
How we may solve this
We need to cover the core of this functionality outside the context of GraphQL. In order to do this, we could reuse the tests that we already have in module Ferry.AidTest for need lists.
Define a new elixir module that represents a region, eg. Ferry.Locations.Region. This could be simple struct that combines a Ferry.Locations.Geocode and a radius expressed in kilometres.
Add a new @spec lists_needs_lists([Ferry.Locations.Region.t()], Date.t()) :: [Ferry.Aid.NeedsList.t()] public function in module Ferry.Aid in order to support this feature. The given date should be in UTC. We need to make sure the dates stored are also in UTC.
Once we are happy that the aggregation works fine, then we can write lightweight tests at the GraphQL level by adding to the existing FerryApi.NeedListSchemaTest. This is to ensure integration between Absinthe and our Aid context.
Add a new query to the existing FerryApi.Schema.NeedList. This query should take a 4 arguments: a latitude, a longitude, a radius in kilometres, and an UTC date. It should return a list of NeedList objects. The resolver for this new query should be pretty straightforward, and simply call Ferry.Aid.lists_needs_lists/2 implemented above.
Is your feature request related to a problem? Please describe. Admins need to see individual groups needs, but also need to able to view aggregated needs lists by geographical region.
Describe the solution you'd like
a GraphQL query that implements this feature. Given a "region" and a given UTC date, the query should return a list of needs that is the aggregation of needs for each group that falls within the region for the given date range.
How we may solve this
We need to cover the core of this functionality outside the context of GraphQL. In order to do this, we could reuse the tests that we already have in module Ferry.AidTest for need lists.
Define a new elixir module that represents a region, eg. Ferry.Locations.Region. This could be simple struct that combines a Ferry.Locations.Geocode and a radius expressed in kilometres.
Add a new
@spec lists_needs_lists([Ferry.Locations.Region.t()], Date.t()) :: [Ferry.Aid.NeedsList.t()]
public function in module Ferry.Aid in order to support this feature. The given date should be in UTC. We need to make sure the dates stored are also in UTC.Once we are happy that the aggregation works fine, then we can write lightweight tests at the GraphQL level by adding to the existing FerryApi.NeedListSchemaTest. This is to ensure integration between Absinthe and our Aid context.
Add a new query to the existing FerryApi.Schema.NeedList. This query should take a 4 arguments: a latitude, a longitude, a radius in kilometres, and an UTC date. It should return a list of NeedList objects. The resolver for this new query should be pretty straightforward, and simply call Ferry.Aid.lists_needs_lists/2 implemented above.
Additional context