feat: add due calculation
This commit is contained in:
parent
4066a4f0b2
commit
956c907545
1 changed files with 18 additions and 1 deletions
|
|
@ -8,13 +8,30 @@ defmodule Putzplan.Tasks.Task do
|
|||
defaults [:read, create: :*]
|
||||
end
|
||||
|
||||
calculations do
|
||||
calculate :due,
|
||||
:date,
|
||||
expr(
|
||||
fragment(
|
||||
"SELECT strftime('%F', ?)", # HACK: to cast to date
|
||||
date_add(
|
||||
completed_tasks.completion || today(),
|
||||
repetition_days,
|
||||
:day
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
sqlite do
|
||||
table "tasks"
|
||||
repo Putzplan.Repo
|
||||
end
|
||||
|
||||
relationships do
|
||||
has_many :completed_tasks, Putzplan.Tasks.CompletedTask
|
||||
has_many :completed_tasks, Putzplan.Tasks.CompletedTask do
|
||||
sort [:completion]
|
||||
end
|
||||
end
|
||||
|
||||
# Attributes are the simple pieces of data that exist on your resource
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue