Restricting aggregate calculations

I have an "aircraft" resource that has this aggregate:
sum :total_flight_hours_mins, :tech_logs, :airborne_time_mins do
description "Total flight hours in minutes for this aircraft"
end
sum :total_flight_hours_mins, :tech_logs, :airborne_time_mins do
description "Total flight hours in minutes for this aircraft"
end
How can I pass in the argument to sum over the tech_logs only for the past X days?
Solution:
```elixir calculate ..., expr(sum(tech_logs, field: :airborne_time_mins, query: [ filter: [expr(... ^arg(:foobar))] ])) do argument :foobar, ......
Jump to solution
2 Replies
ZachDaniel
ZachDaniel3mo ago
You have to use calculations for this
Solution
ZachDaniel
ZachDaniel3mo ago
calculate ..., expr(sum(tech_logs, field: :airborne_time_mins, query: [
filter: [expr(... ^arg(:foobar))]
])) do
argument :foobar, ...
end
calculate ..., expr(sum(tech_logs, field: :airborne_time_mins, query: [
filter: [expr(... ^arg(:foobar))]
])) do
argument :foobar, ...
end

Did you find this page helpful?