From a75a617ed9b81e67101e4400117c4c72048b8cc4 Mon Sep 17 00:00:00 2001 From: Skander Mzali Date: Wed, 3 Jul 2024 13:55:53 -0700 Subject: [PATCH] Update seeds, fix authorization during detection submission --- server/lib/orcasite/radio/detection.ex | 6 +++--- server/priv/repo/seeds.exs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/lib/orcasite/radio/detection.ex b/server/lib/orcasite/radio/detection.ex index 45c65e31..c2b27281 100644 --- a/server/lib/orcasite/radio/detection.ex +++ b/server/lib/orcasite/radio/detection.ex @@ -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) @@ -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 diff --git a/server/priv/repo/seeds.exs b/server/priv/repo/seeds.exs index 01afbb00..60154d84 100644 --- a/server/priv/repo/seeds.exs +++ b/server/priv/repo/seeds.exs @@ -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)