Skip to content

Commit

Permalink
Use correct getter for NotificationInstance (#146)
Browse files Browse the repository at this point in the history
* Use correct getter for NotificationInstance

* Fix check for nil last_notification_id with is_nil instead of '== nil'
  • Loading branch information
skanderm authored Jul 9, 2023
1 parent 0876d95 commit 4b0d09c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
6 changes: 3 additions & 3 deletions server/lib/orcasite/notifications/resources/subscription.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ defmodule Orcasite.Notifications.Subscription do
argument :minutes_ago, :integer, default: 5

filter expr(
(last_notification_id != ^arg(:notification_id) or last_notification_id == nil) and
active == true and
event_type == ^arg(:event_type) and
(is_nil(last_notification_id) or last_notification_id != ^arg(:notification_id)) and
fragment(
"? is null or ? < timezone('UTC', now()) - ?::numeric * interval '1 minute'",
last_notified_at,
last_notified_at,
^arg(:minutes_ago)
) and
active == true
)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@ defmodule Orcasite.Notifications.Workers.SendNotificationEmail do
}) do
notif_instance =
NotificationInstance
|> Ash.Query.for_read(:read, %{id: notification_instance_id})
|> Notifications.read!()
|> Notifications.load([:notification, subscription: [:subscriber]])
|> case do
{:ok, notifs} when is_list(notifs) ->
notifs |> List.last()

{:ok, notif} ->
notif
end
|> Notifications.get!(notification_instance_id)
|> Notifications.load!([:notification, subscription: [:subscriber]])

params =
notif_instance.meta
Expand Down

0 comments on commit 4b0d09c

Please sign in to comment.