Ash FrameworkAF
Ash Framework7mo ago
4 replies
ankit

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

How can I pass in the argument to sum over the tech_logs only for the past X days?
Solution
calculate ..., expr(sum(tech_logs, field: :airborne_time_mins, query: [
  filter: [expr(... ^arg(:foobar))]
])) do
  argument :foobar, ...
end
Was this page helpful?