waseigo
waseigo
AEAsh Elixir
Created by Alan Heywood on 2/14/2023 in #support
Alternative approach for aggregate of aggregate with group by
+1 I'm also interested in learning how to do this
4 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
Apologies for the confusion and thank you for taking the time! I will split the issues, as it's not anymore about P.list().
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
code is an attribute of P.Variant, accessible within P.Item as aggregate variant_code. code is an attribute of P.Category, accessible within P.Item as aggregate category_code. P_item contains a calculation named code that concatenates aggregates variant_code and category_code.
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
@Zach Daniel verified. I remove :code from the preparations:
P.Item |> P.read!() |> P.load!(:variant) -> works. P.Item |> P.read!() |> P.load!(:code) -> unknown error. The other calculation, calculate :tagline, :string, expr(variant_name) , works with P.Item |> P.read!() |> P.load!(:tagline).
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
Weird, because the :code preparation works as intended, and P.Item |> P.read!() delivers records with code: "9381310" etc., as intended.
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
# item.ex
aggregates do
first :sequence_prefix, :sequence, :prefix
first :category_code, [:variant, :family, :category], :code
first :variant_code, :variant, :code
first :variant_name, :variant, :name
first :mpn, :variant, :mpn
end
# item.ex
aggregates do
first :sequence_prefix, :sequence, :prefix
first :category_code, [:variant, :family, :category], :code
first :variant_code, :variant, :code
first :variant_name, :variant, :name
first :mpn, :variant, :mpn
end
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
iex(25)> P.Item |> P.list!(:sequence_prefix)
iex(25)> P.Item |> P.list!(:category_code)
iex(25)> P.Item |> P.list!(:variant_code)
iex(25)> P.Item |> P.list!(:sequence_prefix)
iex(25)> P.Item |> P.list!(:category_code)
iex(25)> P.Item |> P.list!(:variant_code)
All fail with:
** (Ash.Error.Unknown) Unknown Error

* Must provide field type for list
(elixir 1.14.0) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
(ash 2.6.3) lib/ash/error/error.ex:196: Ash.Error.to_error_class/2
(bouketo 0.1.0) lib/bouketo/portfolio.ex:1: Bouketo.Portfolio.list!/3
(stdlib 4.2) erl_eval.erl:744: :erl_eval.do_apply/7
(elixir 1.14.0) src/elixir.erl:283: :elixir.eval_forms/3
(elixir 1.14.0) lib/module/parallel_checker.ex:100: Module.ParallelChecker.verify/1
(iex 1.14.0) lib/iex/evaluator.ex:329: IEx.Evaluator.eval_and_inspect/3
(iex 1.14.0) lib/iex/evaluator.ex:303: IEx.Evaluator.eval_and_inspect_parsed/3
(iex 1.14.0) lib/iex/evaluator.ex:292: IEx.Evaluator.parse_eval_inspect/3
(iex 1.14.0) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
(iex 1.14.0) lib/iex/evaluator.ex:32: IEx.Evaluator.init/4
(stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
(bouketo 0.1.0) lib/bouketo/portfolio.ex:1: Bouketo.Portfolio.list!/3
** (Ash.Error.Unknown) Unknown Error

* Must provide field type for list
(elixir 1.14.0) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
(ash 2.6.3) lib/ash/error/error.ex:196: Ash.Error.to_error_class/2
(bouketo 0.1.0) lib/bouketo/portfolio.ex:1: Bouketo.Portfolio.list!/3
(stdlib 4.2) erl_eval.erl:744: :erl_eval.do_apply/7
(elixir 1.14.0) src/elixir.erl:283: :elixir.eval_forms/3
(elixir 1.14.0) lib/module/parallel_checker.ex:100: Module.ParallelChecker.verify/1
(iex 1.14.0) lib/iex/evaluator.ex:329: IEx.Evaluator.eval_and_inspect/3
(iex 1.14.0) lib/iex/evaluator.ex:303: IEx.Evaluator.eval_and_inspect_parsed/3
(iex 1.14.0) lib/iex/evaluator.ex:292: IEx.Evaluator.parse_eval_inspect/3
(iex 1.14.0) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
(iex 1.14.0) lib/iex/evaluator.ex:32: IEx.Evaluator.init/4
(stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
(bouketo 0.1.0) lib/bouketo/portfolio.ex:1: Bouketo.Portfolio.list!/3
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
I'll check all the dependent values of this
calculate :code, :string, expr(type(sequence_prefix, :string) <> type(category_code, :string) <> type(variant_code, :string))
calculate :code, :string, expr(type(sequence_prefix, :string) <> type(category_code, :string) <> type(variant_code, :string))
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
So, the :code calculation fails
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
Interestingly, P.Item has an aggregate first :variant_code, :variant, :code, and
preparations do
prepare build(load: [:sequence_prefix, :category_code, :variant_code, :code, :tagline, :mpn])
end
preparations do
prepare build(load: [:sequence_prefix, :category_code, :variant_code, :code, :tagline, :mpn])
end
So, :variant_code based on the related :variant is successfully prepared.
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
This is super weird. This works:
P.Variant |> Ash.Query.filter(name == "EWM400") |> P.read_one!() |> P.load!(:item)
P.Variant |> Ash.Query.filter(name == "EWM400") |> P.read_one!() |> P.load!(:item)
This also works:
P.Item |> Ash.Query.filter(variant_name == "EWM400") |> P.read_one!()
P.Item |> Ash.Query.filter(variant_name == "EWM400") |> P.read_one!()
This fails with unknown error:
P.Item |> Ash.Query.filter(variant_name == "EWM400") |> P.read_one!() |> P.load!(:variant)
P.Item |> Ash.Query.filter(variant_name == "EWM400") |> P.read_one!() |> P.load!(:variant)
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
Actually it chokes at the very first record.
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
The offending record can be read, but loading :variant leads to the unknown error. I'll check my data.
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
Indeed, it choked after a few records. Let me check.
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
oh man, thank you so much for that Ash.Api.list() !
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
yep, just checked, this one is still broken
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
iex(2)> P.Brand |> P.list(:name)
[debug] QUERY OK source="brands" db=0.9ms decode=6.4ms queue=2.8ms idle=1036.7ms
SELECT coalesce(array_agg(b0."name"::text), $1::text[])::text[] FROM "brands" AS b0 [[]]
AshPostgres.DataLayer.run_aggregate_query/3, at: lib/data_layer.ex:690
{:ok,
["TOREX", "WAM", "OLI", "TECNO CM", "ABB", "Solimar Pneumatics", "Fike", "MAP",
"EXTRAC", "CIMMA", "TECTRA", "SEPCOM", "Telemecanique", "MVM", "Lainyl"]}
iex(2)> P.Brand |> P.list(:name)
[debug] QUERY OK source="brands" db=0.9ms decode=6.4ms queue=2.8ms idle=1036.7ms
SELECT coalesce(array_agg(b0."name"::text), $1::text[])::text[] FROM "brands" AS b0 [[]]
AshPostgres.DataLayer.run_aggregate_query/3, at: lib/data_layer.ex:690
{:ok,
["TOREX", "WAM", "OLI", "TECNO CM", "ABB", "Solimar Pneumatics", "Fike", "MAP",
"EXTRAC", "CIMMA", "TECTRA", "SEPCOM", "Telemecanique", "MVM", "Lainyl"]}
this works
119 replies
AEAsh Elixir
Created by waseigo on 2/12/2023 in #support
How to Ash-idiomatically get all unique values of an attribute across all records?
wut 🥴
119 replies