ash_postgres/test/support/complex_calculations/resources/skill.ex
Zach Daniel 37cc01957d
improvement!: 3.0 (#227)
* WIP

* chore: fix mix.lock merge issues

* improvement: upgrade to 3.0

* chore: remove `repo.to_tenant`

* chore: continue removal of unnecessary helper

* chore: use `Ash.ToTenant`
2024-03-27 16:52:28 -04:00

58 lines
1.3 KiB
Elixir

defmodule AshPostgres.Test.ComplexCalculations.Skill do
@moduledoc false
use Ash.Resource,
domain: AshPostgres.Test.ComplexCalculations.Domain,
data_layer: AshPostgres.DataLayer
actions do
default_accept(:*)
defaults([:create, :read, :update, :destroy])
end
aggregates do
first :latest_documentation_status, [:documentations], :status do
sort(timestamp: :desc)
end
end
attributes do
uuid_primary_key(:id)
attribute(:removed, :boolean, default: false, allow_nil?: false, public?: true)
end
calculations do
calculate :status, :atom do
calculation(
expr(
if is_nil(latest_documentation_status) do
:pending
else
latest_documentation_status
end
)
)
end
end
postgres do
table "complex_calculations_skills"
repo(AshPostgres.TestRepo)
end
relationships do
belongs_to(:certification, AshPostgres.Test.ComplexCalculations.Certification) do
public?(true)
end
has_many :documentations, AshPostgres.Test.ComplexCalculations.Documentation do
public?(true)
sort(timestamp: :desc, inserted_at: :desc)
end
has_one :latest_documentation, AshPostgres.Test.ComplexCalculations.Documentation do
public?(true)
sort(timestamp: :desc, inserted_at: :desc)
end
end
end