Skip to content

Commit ed555d2

Browse files
committed
fix(front): fetch service accounts with describe_many endpoint
1 parent 6d19cfc commit ed555d2

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

front/lib/front/rbac/groups.ex

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,22 @@ defmodule Front.RBAC.Groups do
130130
member_user_ids = members |> Enum.map(& &1.id)
131131
non_member_ids = group.member_ids -- member_user_ids
132132

133-
# N+1 :see_no_evil
134133
service_accounts =
135-
non_member_ids
136-
|> Enum.map(fn service_account_id ->
137-
Front.ServiceAccount.describe(service_account_id)
138-
end)
139-
|> Enum.map(fn
140-
{:ok, service_account} ->
141-
%{
142-
id: service_account.id,
143-
name: service_account.name,
144-
avatar: ""
145-
}
134+
Front.ServiceAccount.describe_many(non_member_ids)
135+
|> case do
136+
{:ok, service_accounts} ->
137+
service_accounts
146138

147139
_ ->
148-
nil
149-
end)
150-
|> Enum.filter(& &1)
140+
[]
141+
end
142+
|> Enum.map(
143+
&%{
144+
id: &1.id,
145+
name: &1.name,
146+
avatar: ""
147+
}
148+
)
151149

152150
group |> Map.put(:members, members ++ service_accounts)
153151
end

0 commit comments

Comments
 (0)