Sakthibalan
Aggregate the average story point for the week
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())
Most Liked
FlyingNoodle
I would write a custom expression for a start_of_week and end_of_week or similar. See: Ash.CustomExpression — ash v3.29.3
1
zachdaniel
Creator of Ash
Gotcha, then yeah a custom expression, or a fragment, or lazy would work. i.e
fragment("postgres_code_that_gets_you_start_of_week") or
lazy({SomeModule, :start_of_week, []})
1
Popular in Questions
The Elixir Typespec docs show the following syntax for keyword lists in typespecs:
# ...
| [key: type] # keyword lists...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar.
I p...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
Other popular topics
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)?
Would
mix ecto.rollback -v 200809061...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









