Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: attendees with user as nil #395

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading