use Ash instead of Domain module for read in docs (#1430)

This commit is contained in:
Barnabas Jovanovics 2024-09-02 16:58:04 +02:00 committed by GitHub
parent 2c754f90a6
commit 0dc3a75aaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -328,7 +328,7 @@ defmodule Helpdesk.Support.Ticket.Relationships.TicketsAboveThreshold do
use Ash.Resource.ManualRelationship use Ash.Resource.ManualRelationship
require Ash.Query require Ash.Query
def load(records, _opts, %{query: query, actor: actor, authorize?: authorize?}) do def load(records, _opts, %{query: query} = context) do
# Use existing records to limit results # Use existing records to limit results
rep_ids = Enum.map(records, & &1.id) rep_ids = Enum.map(records, & &1.id)
@ -336,7 +336,7 @@ defmodule Helpdesk.Support.Ticket.Relationships.TicketsAboveThreshold do
query query
|> Ash.Query.filter(representative_id in ^rep_ids) |> Ash.Query.filter(representative_id in ^rep_ids)
|> Ash.Query.filter(priority > representative.priority_threshold) |> Ash.Query.filter(priority > representative.priority_threshold)
|> Helpdesk.Support.read!(actor: actor, authorize?: authorize?) |> Ash.read!(Ash.Context.to_opts(context))
# Return the items grouped by the primary key of the source, i.e representative.id => [...tickets above threshold] # Return the items grouped by the primary key of the source, i.e representative.id => [...tickets above threshold]
|> Enum.group_by(& &1.representative_id)} |> Enum.group_by(& &1.representative_id)}
end end