Skip to content

Commit

Permalink
fix: attendees with user as nil (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruilopesm authored Feb 6, 2024
1 parent 7468ec8 commit d04f322
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/safira/accounts/accounts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ defmodule Safira.Accounts do
join: a in assoc(r, :attendee),
preload: [attendee: a]
)
|> Enum.map(fn x -> x.attendee |> Repo.preload(:user) end)
|> Enum.map(fn x -> x.attendee end)
|> Enum.filter(fn x -> not is_nil(x.user_id) end)
|> Enum.map(fn x -> Repo.preload(x, :user) end)
else
Repo.all(from a in Attendee, where: not is_nil(a.user_id))
|> Repo.preload(:user)
Expand Down
1 change: 1 addition & 0 deletions lib/safira/contest/contest.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ defmodule Safira.Contest do
def get_badge_preload!(id) do
Repo.get!(Badge, id)
|> Repo.preload(attendees: [:user])
|> Map.update!(:attendees, fn x -> Enum.filter(x, fn x -> not is_nil(x.user_id) end) end)
end

def get_badge_description(description) do
Expand Down

0 comments on commit d04f322

Please sign in to comment.