refactor: improve groups LiveView based on code review feedback
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon 2026-01-28 10:33:27 +01:00
parent 3eb4cde0b7
commit ddc8335cc0
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
8 changed files with 109 additions and 104 deletions

View file

@ -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