Sangres
Sangres
AEAsh Elixir
Created by Sangres on 1/18/2024 in #support
error with keyset pagination and random sort
As the title says i'm trying to define an action that should list my posts in a random sort while using the keyset pagination. This is the action that im calling
read :list do
...
transaction? true

prepare fn query, context ->
Ash.Query.before_action(query, fn query ->
OnmyjobsApp.Repo.query!("select setseed(#{0.42})")
query
end)
end

prepare before_action(&list_preparation/1)
prepare build(sort: [Ash.Sort.expr_sort(fragment("RANDOM()"))])
pagination keyset?: true, required?: true, countable: :by_default, default_limit: 10
end
read :list do
...
transaction? true

prepare fn query, context ->
Ash.Query.before_action(query, fn query ->
OnmyjobsApp.Repo.query!("select setseed(#{0.42})")
query
end)
end

prepare before_action(&list_preparation/1)
prepare build(sort: [Ash.Sort.expr_sort(fragment("RANDOM()"))])
pagination keyset?: true, required?: true, countable: :by_default, default_limit: 10
end
I know that the problem is not the list_preparation that i'm calling. The following problem is when i put the last two rows together
8 replies
AEAsh Elixir
Created by Sangres on 9/4/2023 in #support
set action argument in form
I have two resources: User and Account I'm creating an AshFrom and use that to create an User. On submit, just before creating the User i need to create an account and pass it as argument to the action used in the for_create of the form. Unfortunately i can't manage to find a way to set the argument in the form before it calls the action
16 replies