Execute an after_action only on single action or customize it for bulk actions.
Hello!
I have an resource that must send a push notification when one of it's push notifications are updated.
The problem is that I should aggregate bulk actions and send a single push notification in cases where multiple records go to the same user (which is the related resource). I tried to look on the internet and on this forum for a way to do that but couldn't find anything.
But It would be something like sending a message saying that a user has "X 'something' to work on" (in case of bulk) vs saying "You have a 'something' to work on" and I don't want to spam the users with a message that meant to be sent for the single relationship update when we're doing bulks.
2 Replies
some thoughts:
if you're using ash's bulk actions, you can use this with your changes so they only fire once per batch:
https://hexdocs.pm/ash/changes.html#batches
otherwise, if you're trying to batch just the notifications but the actual actions are done one by one, might be able to wire something together with notifiers and do some batching manually?
https://hexdocs.pm/ash/notifiers.html
I'm using Ash bulk actions. but I'll take a look in that think with the notifiers too! thank you!