refactor: improve groups LiveView based on code review feedback
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3eb4cde0b7
commit
ddc8335cc0
8 changed files with 109 additions and 104 deletions
|
|
@ -274,18 +274,18 @@ defmodule Mv.Membership do
|
|||
|
||||
"""
|
||||
def get_group_by_slug(slug, opts \\ []) do
|
||||
actor = Keyword.get(opts, :actor)
|
||||
load_opts = Keyword.get(opts, :load, [:members, :member_count])
|
||||
load = Keyword.get(opts, :load, [])
|
||||
|
||||
require Ash.Query
|
||||
|
||||
query =
|
||||
Mv.Membership.Group
|
||||
|> Ash.Query.filter(slug == ^slug)
|
||||
|> Ash.Query.load(load_opts)
|
||||
|> Ash.Query.load(load)
|
||||
|
||||
opts_with_actor = if actor, do: [actor: actor], else: []
|
||||
|
||||
Ash.read_one(query, opts_with_actor)
|
||||
opts
|
||||
|> Keyword.delete(:load)
|
||||
|> Keyword.put_new(:domain, __MODULE__)
|
||||
|> then(&Ash.read_one(query, &1))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue