How to count weekly average points from tasks resource?
defmodule Ash.Assignments.Milestone do
...
attributes do
uuid_primary_key :id
attribute :title, :string
attribute :description, :string
attribute :due_date, :utc_datetime
timestamps()
end
relationships do
has_many :tasks, Ash.Task,
destination_attribute: :milestone_id,
public?: true
end
aggregates do
avg :week_avg_story_point, :tasks, :story_point do
public? true
filter expr(inserted_at >= start_date() and inserted_at <= end_date())
end
end
end
defmodule Ash.Task do
...
attributes do
uuid_primary_key :id
attribute :title, :string
attribute :description, :string
attribute :status, :atom, public?: true, constraints: [one_of: [:todo, :in_progress, :done]]
attribute :due_date, :utc_datetime, public?: true
attribute :story_point, :integer
timestamps()
end
relationships do
belongs_to :milestone, Tuesday.Assignments.Milestone,
allow_nil?: true,
public?: true
end
end
Ash.Milestone
|> Ash.Query.load(:week_avg_story_point)
|> Ash.read!()
How to give proper filter expression for between two dates:
eg: filter expr(inserted_at >= start_date() and inserted_at <= end_date())