Skip to content

Commit

Permalink
Update seeds, fix authorization during detection submission
Browse files Browse the repository at this point in the history
  • Loading branch information
skanderm committed Jul 3, 2024
1 parent 8be1cfa commit a75a617
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions server/lib/orcasite/radio/detection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ defmodule Orcasite.Radio.Detection do
|> Ash.Changeset.for_update(:update, %{
visible: !Enum.all?(candidate.detections, &(!&1.visible))
})
|> Ash.update!()
|> Ash.update!(authorize?: false)

{:ok, detection}
end)
Expand Down Expand Up @@ -261,12 +261,12 @@ defmodule Orcasite.Radio.Detection do
min_time: datetime_min(candidate.min_time, detection.timestamp),
max_time: datetime_max(candidate.max_time, detection.timestamp)
})
|> Ash.update!()
|> Ash.update!(authorize?: false)
end

detection
|> Ash.Changeset.for_update(:update_candidate, %{candidate: candidate})
|> Ash.update()
|> Ash.update(authorize?: false)
end)
|> Ash.Changeset.after_action(fn changeset, detection ->
# Happens second
Expand Down
3 changes: 2 additions & 1 deletion server/priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,11 @@ Orcasite.Accounts.User
|> Enum.find(fn feed -> feed.slug == attrs[:slug] end)
|> case do
%{id: feed_id} ->
detection_attrs = Map.drop(attrs, [:slug])
Orcasite.Radio.Detection
|> Ash.Changeset.for_create(
:submit_detection,
Map.merge(attrs, %{feed_id: feed_id, send_notifications: false})
Map.merge(detection_attrs, %{feed_id: feed_id, send_notifications: false})
)
|> Ash.create!(authorize?: false)

Expand Down

0 comments on commit a75a617

Please sign in to comment.