Skip to content

Commit

Permalink
fix: task
Browse files Browse the repository at this point in the history
  • Loading branch information
ruilopesm committed Feb 5, 2024
1 parent 8d73e75 commit 56f34d7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/safira/jobs/spotlight_badge.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ defmodule Safira.Jobs.SpotlightBadge do
"""
import Ecto.Query, warn: false

alias Safira.Accounts.Attendee
alias Safira.Contest
alias Safira.Contest.Badge
alias Safira.Contest.{Badge, Redeem}
alias Safira.Repo

@spec run(integer()) :: :ok
Expand All @@ -21,16 +20,16 @@ defmodule Safira.Jobs.SpotlightBadge do
end

defp list_eligible_attendees(badge_id) do
Attendee
|> join(:inner, [a], r in assoc(a, :redeems))
|> where([a, r], r.spotlighted == true and r.badge_id != ^badge_id)
Redeem
|> where([r], r.spotlighted == true and r.badge_id != ^badge_id)
|> select([r], r.attendee_id)
|> Repo.all()
end

defp create_redeem(attendee, badge) do
defp create_redeem(attendee_id, badge) do
Contest.create_redeem(
%{
attendee_id: attendee.id,
attendee_id: attendee_id,
staff_id: 1,
badge_id: badge.id
},
Expand Down

0 comments on commit 56f34d7

Please sign in to comment.