Skip to content

Commit

Permalink
feat: remove funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
AfonsoMartins26 committed Feb 11, 2025
1 parent 0ddf4f0 commit d562c53
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions lib/safira/contest.ex
Original file line number Diff line number Diff line change
Expand Up @@ -376,32 +376,6 @@ defmodule Safira.Contest do
Repo.get!(DailyPrize, id)
end

def remove_badgeredeem_from_attendee(badge_id, attendee_id) do
from(br in BadgeRedeem, where: br.badge_id == ^badge_id and br.attendee_id == ^attendee_id)
|> Repo.delete_all()
end

def remove_badgeredeem_transaction(badge_id, attendee_id) do
Multi.new()
|> Multi.run(:get_badge, fn _repo, _changes ->
get_badge!(badge_id)
end)
|> Multi.run(:get_attendee, fn _repo, _changes ->
Accounts.get_attendee!(attendee_id)
end)
|> Multi.update(
:remove_badge_from_attendee,
remove_badgeredeem_from_attendee(badge_id, attendee_id)
)
|> Multi.merge(fn %{get_badge: badge, get_attendee: attendee} ->
Contest.change_attendee_tokens_transaction(
attendee,
attendee.tokens - badge.tokens
)
end)
|> Repo.transaction()
end

@doc """
Creates a daily prize.
Expand Down

0 comments on commit d562c53

Please sign in to comment.